Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 724
Petah Avatar asked Apr 11 '13 02:04

Petah


3 Answers

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.

like image 57
Adam S Avatar answered Nov 12 '22 19:11

Adam S


git diff --stat master origin/master

Example output:

classes/Mammoth/Article.php                                            |   12 ++++++++++--
classes/Mammoth/Article/Admin/Section/Controller.php                   |   34 +++++++++++++++++-----------------
classes/Mammoth/Article/Filter.php                                     |   14 +++++++-------
classes/Mammoth/Article/Section.php                                    |   18 ++++++++++--------
classes/Mammoth/Article/Section/IMySQL.php                             |    2 +-
migrations/20130411111424_ChangeNameToURIOnSectionsTable.php           |   14 --------------
migrations/sql/up/20130411111424_ChangeNameToURIOnSectionsTable.sql    |    5 -----
solr-core/conf/schema.xml                                              |    2 +-
views/admin/section/form.php                                           |    8 ++++----
views/admin/section/view.php                                           |   10 +++++-----
10 files changed, 55 insertions(+), 64 deletions(-)
like image 43
Michael Robinson Avatar answered Nov 12 '22 20:11

Michael Robinson


If you're up-to-date with your fetching (something all the other answers here presume as well)

$ git checkout
Your branch is ahead of 'origin/master' by 9 commits.
  (use "git push" to publish your local commits)

To get that info for all branches,

$ git branch -avvv
like image 20
jthill Avatar answered Nov 12 '22 18:11

jthill