Take the 2-minute tour ×

I want to find out the last thing that I pushed, not the last thing i commited, but pushed.

Is there a git command for this?

Context: I want to squash some commits before merging my dev_branch with a master branch but I have been told you can not rebase anything that is already pushed (is this true?).

So i would like to know what was the last commit that I cannot include in this rebase.

share|improve this question

1 Answer 1

up vote 9 down vote accepted

If you mean the last commit you pushed to the master branch then, assuming your remote is origin:

git rev-parse origin/master

This will show you the commit ID of the tip of the master branch of the origin origin, as your local repository is currently aware. This may mean that the commit is someone else's commit, if someone else pushed commits after you did and you have since fetched that branch.

git show -p origin/master

This command will give you information about the commit, including the commit ID, author, log message, and diff to its parent commit(s).

One of my favorite Git commands for doing exactly this kind of inspection:


This will display a nice ASCII-art graph of the commit history, and each commit will show any refs that are targeting it. This way you can, at a single glance, see branches and merges in history and easily see where origin/master is in relation to your own master.

share|improve this answer
wow thanks cdhowie that last command is awesome, its really useful! i should probably ask this in a seperate question but what is considered better -git rebase -i -git merge --squash What i want to do, is merge my dev branch with master, but have my 100+ commmits compressed into say 4. Not 1, as there are probably 4 key points in its history –  chrispepper1989 Mar 21 '13 at 16:31
If you have pushed your dev branch then squashing it is a bad idea, as others will have been free to branch from your work. If it's public, don't change it. If it is not public then git rebase -i will let you choose which distinct commits you want to retain in the history and which you want to squash into them. git merge --squash will only give you the opportunity to create one commit, so ultimately it depends on how many commit objects you want. –  cdhowie Mar 21 '13 at 16:34

Your Answer


