Essay record

Git: Get Ahead/Behind Commit Messages in Git Status

Record
Essay / / 1 min read / 114 words
Tags
Unfiled

DISCLOSURE: Some links may be affiliate links. Details

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

Built with CloudSeed Rust