Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Show number of commits behind upstream

Tags:

git

github

Our teams tend to not keep track of how many commits they are behind the latest released code. We want to notify them of that, but getting the information is the hard part, the notify part is done.

What I would like to understand how to pull the git log down, do a git command that outputs "Branch x is behind branch y by 5 commits". I don't want to have to checkout the branch as it pulls down our 600mb+ repo each time for all of our branches, plus I'm running low on drive space. I have found similar questions on stack overflow that reference bash scripts that only work locally, or the ones that point to remote return blank. I'm still learning git and bash, please bear with me.

like image 223
Josh Avatar asked Mar 13 '15 15:03

Josh


1 Answers

What you need is git rev-list (reverse chronological order of commits).

After cloning a repo (make sure the remote is set and git fetch origin has been performed), to get ahead number of the branch from master, try

git rev-list origin/master..origin/feature/SuperCoolBranch --count

switch the branches around to find out the behind number.

like image 77
Sai Puli Avatar answered Nov 23 '22 07:11

Sai Puli