Git: Get Ahead/Behind Commit Messages in Git Status

Date: 2016-07-25 |

**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.

Sources

Want more like this?

The best / easiest way to support my work is by subscribing for future updates and sharing with your network.