Search code examples
gitversion-control

Git check if there is outstanding commits to push


Is there a command I can run to check if there is any commits to push to origin/master?

git [some command] origin master

Would output something like:

origin/master is behind by 7 commits

Solution

  • Here are two ways to list the "extra" commits you have which are not on origin/master:

    git log --oneline origin/master..HEAD
    git rev-list --oneline ^origin/master HEAD
    

    The --oneline just lists them in a shorter format. Also, if your branch tracks origin/master, a simple git status will show you.