Getting Repository Insights From Git

Getting Repository Insights From Git

GitHub has some cool features. One of the page on GitHub I usually go through when I come across any popular repository is itsΒ contributors page.



From the above example, we can get to know many statistics like how the repository is growing, number of people contributing, number of commits they have made and lot more.

Apparently, my team uses a private repository on BitbucketΒ and Bitbucket don’t have anything like contributors page just like how we see above. Maybe because Bitbucket is mostly used by enterprises to host private repositories and they won’t have any external contributors. It makes sense GitHub having contributors page because it hosts 1000s of open source projects and has numerous contributors.

Since Bitbucket doesn’t have this feature, I thought of exploring some git commands to extract these statistics from my git repository. [Got one more opportunity to learn more about Git πŸ™‚ ]

To start with, I figured out how to find number of commits made by each developer.

$ git shortlog -s -n

This would give me a list of all the contributors with number of commits they have done.

To be continued…


SwiftCode at BNMIT

Firstly, check out our technology stack :

It is Play framework, REST API, Java, AngularJS, MySQL, we deploy our application on AWS, Heroku. All our development happens over Lubuntu, a lightweight and fast operating system. We make use of Git along with GitHub for version control.

What is SwiftCode ?

SwiftCode program is intended to show a modern age computer science graduate how to build scalable and robust applications using state of the art techniques and design methodologies that have shaped software today.

This blog post beautifully explains how we set up collaborative development environment for our workshop : How to Quickly Set Up Collaborative Software Development Environments

On August 20th, we hosted our first workshop at BNMIT engineering college, Bangalore. We had 25 students from Computer/Information Science department.

On the first and second day, Sandeep and Akshay took the session on Java Play framework, explaining how to build a RESTful application. They completed the backend side of the application. Students were often made to commit and push their code on Github. At the end of day 2, Shrita showed how to test our APIs using the Postman.

On the third day, Prarthana took a session on front-end development, talking about how responsive websites could be built using bootstrap, architecture of Model-View-Controller (MVC) and AngularJS.

At the end of the training, all students were able to build a social media (similar to facebook) application on their own. They had soo much fun and learned a lot.

You can see all the repositories created by them at our GitHub org :

This slideshow requires JavaScript.

Image source : SwiftCode

It’s a great start to our long journey. Keep waiting to know about our next stop! πŸ™‚

[To be continued…]

Why git ?

Why git ?

Hey people,

This post is dedicated for my friends who are new to FOSSΒ  world or would like to get started with git.

Every time I start to explain about git to my friends I give them this problem statement and ask them to give me the solution :

You are in a project team which consist of 5 people and each of them stay in 5 different countries. Your project is to build some application where all 5 of you have to do some code contribution to it. Now, how this work can do done collaboratively ?

(I know that people usually share the code via storage devices like USB drives. πŸ˜€ That’s the reason I said your team mates are in different countries.)

Do you think you can share the code snippets over email ?
Or by using any cloud platforms like dropbox, google drive, etc ?

Well, these approaches are possible too but they are not very much efficient. Management of the code becomes hectic.

This is where the git comes for the rescue.

Git is a popular version control system (VCS) used for software development. As I have seen, most of the open source projects development are done with this VCS. Git has been beautifully designed with graph theory tree model.
Git provides lots of features like code tracking, reverting, keeping the development of new features separately from the main code base using branches.

$ man git

Documentation of git on man page is not much helpful. One has to look for stack overflow for most problems he usually faces.Β  For instance, three of the top five highest voted questions on Stack Overflow are questions about how to carry out relatively simple tasks on git.

Steve Bennett explains about 10 things he about git.
Some of his points are true.
It may be complex, lengthy process, new technology to learn, but it will keep developers life simpler. πŸ™‚

So, no more sharing code via storage drives, emails, dropbox or google drives. You can use git, push the code onto some server like gitlab, github or bitbucket and work collaboratively. πŸ™‚

In my next post, I’ll write about how to work collaboratively using git. πŸ™‚

Mid-night git session at dgplug

I’m using git since few months. The world of git is too big. You have lot of things to explore in that.

One way to explore things in any technology or programming language is by solving the problems.

On #dgplug (Durgapur Linux Users’ Group) channel, someone had a problem with git.

The problem statement goes like this :

A person has made 4 commits and sent a pull request. Now, the owner of the GitHub repository is asking that person to remove the last 2 commits i.e commit number – 3 and commit number – 4. How can one remove the last 2 commits keeping first 2 commits as it is ?

Sayan was there to help in this problem. He took a hands-on session at that late night (It was around 11.45 p.m IST).

If you want to learn to solve this problem, just follow these instructions :

First we cloned this repository :

$ git clone

As usual, you need to change your current directory to project directory, so hit :

$ cd pym

Now you are inside the project directory. We moved into code directory of the project. To do this, hit :

$ cd code

We added a new file called

After this, check the status of the git by executing :

$ git status

You will be able to see file name in red color under Untracked files. This tells that the file has not been tracked by the git.
Please remember this point as this is important.

Next do :

$ git diff

This will not show any changes as of now.

Now add this statement in argvtest.pyΒ  file :

print 'hello world'

Note : file is already present in the code directory

Now again, check the status of the git by executing :

$ git status

Can you see the changes now ?

We can see file in red color under modified files and file in red color under Untracked files.

Now do :

$ git diff

You can see the changes you have made. If you have added a new line you will be able see it in green color preceding with + (plus) symbol. If you have deleted a line you will be able see it in red color preceding with – (minus) symbol.

I hope you have completely understood till here. πŸ™‚

Now do :

$ git add

The file is now staged. To check this, do :

$ git status

You can see the color of the modified file i.e has been changed from red to green. This represent that the file has been staged and tracked by git.

Now do :

$ git diff

You don’t see nothing, because by default git diff shows whatever is there in modified.

Since we have nothing in modified area, it doesn’t show anything. file is now staged and if you want to see the changes, do :

$ git diff --staged

This will show the changes in the staged area.

Note : $ git diff --staged and $ git diff --cached does same thing.

Now let’s commit this by doing :

$ git commit

This will open a text editor and you will see the text in there “Changes to be committed”.

Now write the commit message in the first line, then save and quit. (Lines starting with # will be ignored)

To see your commit, do :

$ git log

To see the changes made in the commit, do :

$ git log -p

There will be lot of commits, now do :

$ git reset --soft HEAD~1

$ git status

See the output. Understood what $ git reset --soft HEAD~1 did ?

Soft reset brings the changes to staged.


$ git reset HEAD

will bring into unstaged area as you can see in the output, it shows the file name under Unstaged changes.

HEAD is referred as the topmost commit in git just like tip is referred as the topmost commit in mercurial.

HEAD~1 takes 1 commit behind.
HEAD~2 takes 2 commit behind and so on…

Important note : If we do $ git reset --soft HEAD then we won’t loose the changes made in other commits which were removed.

I hope after reading this post you would have understood how to solve the above mentioned problem. πŸ™‚