Maybe you’ve had to step away from working on a new feature to go and fix a production bug. You come back to your feature branch and you want to be reminded of what the last bit of work was on this branch that you haven’t yet pushed to the remote repository. In other words, how to show your local git commits. So you need to find out how to “git check commits” – see the unpushed git commits you still have on the branch. You might find yourself searching for “git list unpushed commits“, or “git view unpushed commits“. This post will explain how to use a git command to show your unpushed commits.
Table of contents
git show unpushed commits on current branch
This solution will get you a list of all the unpushed commits on your current branch so that you can check your commits. First of all, make sure you are on the correct branch! Next use git status
to see how many unpushed commits there are on your current branch. Then use the git log
command to view the unpushed commits on the branch :
git log origin/master..HEAD
The image below shows an example of using both of those commands to check your commits, and the subsequent result :
View a summary of unpushed commits on current branch
The git cherry
command can be used to see the “commits which have not yet been applied to the upstream branch” – git check commits in other words. Use that command to show this list of local git commits:
//this command....
$ git cherry -v
//shows this result...
+ 6915248b8b429a1573e44ba6ff202e20f860b2d2 Adjusted button text
+ 01b1028b8f30e6c23e73d257a89b2eb7678b283a Increased header height
As you can see this command lets you view all your unpushed commits on the current git branch in summary format. It shows the SHA1 id and the commit message for each. If all you wanted was an overview, and a reminder of what changes you’ve already committed, but not pushed, then this is a great solution to show git commits not pushed.
It’s important to note the relevance of the + symbol at the start of each line. In the git documentation about the git cherry
command, it states each line is “…. prefixed with -
for commits that have an equivalent in <upstream>, and +
for commits that do not.“
View (and undo) the last commit
But if you want more detail on how to view the last commit then jump to my other post explaining how to do just that. And when you’ve viewed it, read this if you want to undo the last commit.
Summary
This post has shown you how to list and see your unpushed git commits, or in other words how to ‘git show commits not pushed‘ or “git check commits”. You now know how to list and check unpushed commits.