386

Possible Duplicate:
Viewing Unpushed Git Commits

How do I list all commits which have not been pushed to the origin yet?

Alternatively, how to determine if a commit with particular hash have been pushed to the origin already?

1
  • 3
    Starting with Git 2.5+ (Q2 2015), the actual answer would be git log @{push}... See that new shortcut @{push} (referencing the remote tracking branch you are pushing to) in my answer at "Viewing Unpushed Git Commits" Commented Jun 8, 2015 at 22:45

2 Answers 2

494

git log origin/master..master

or, more generally:

git log <since>..<until>

You can use this with grep to check for a specific, known commit:

git log <since>..<until> | grep <commit-hash>

Or you can also use git-rev-list to search for a specific commit:

git rev-list origin/master | grep <commit-hash>

Sign up to request clarification or add additional context in comments.

6 Comments

What if you have already git fetch'd, and the origin contains more commits which you haven't pulled yet? then origin/develop is newer than develop - will this answer still give the expected list of commits not yet pushed to the origin?
@Kidburla Yes, this still works in that situation. git log origin/develop..develop will list any commits that haven't been pushed to the origin's develop branch. The reverse, git log develop..origin/develop will list any commits that are in origin's develop but haven't been pulled into the local develop yet.
If <until> is supposed to be the current HEAD (the last commit on the checked out branch), then it can simply be omitted. The two dots are still required though: git log origin/master.. (same as git log origin/master..HEAD)
Very well explained with the general case (second snippet). I'd expect there be a command or shortcut for that operation as it's very useful and frequently needed. Is there a way to define a shorter version of getting the commits that aren't on the remote yet but to reside on the local branch?
"git log origin/master..HEAD" is what worked for me.
|
41

how to determine if a commit with particular hash have been pushed to the origin already?

# list remote branches that contain $commit git branch -r --contains $commit 

1 Comment

try this : git cherry -v origin/master

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.