Git: Get Ahead/Behind Commit Messages in Git Status
Problem: I’m using Git to version control my project. Currently, ‘git status’ returns the number of commits ahead and behind I am for origin/master. However, I want git status to return the number of commits ahead and behind I am for a different branch. How do I do this?
Solution: With git 1.8 and later, the syntax is as follows:
While on the branch you’d like to track the difference between, run:
git branch –set-upstream-to remotename/branchname
Now when you run git status, you’ll see the ahead/behind commit differences for the new branch you just set.