git,

How to list unpushed commits with git log

Aug 24, 2022 · 1 min read · Post a comment

Another cool command by Git and this time we are going to try to list all local (unpushed) commits. As always, there’s more than one way to shine a penny.

Prerequisites

  • Git

Solution

Go to your current Git repo and run the following command:

git log origin/main..HEAD

HEAD is a ref that points to the latest commit of a branch. Simply put, you can think of it as a commit hash.

Another more recent command to show commits you haven’t pushed yet is:

git log @{push}..

To view all not pushed yet commits across all branches in a Git repo, run:

git log --branches --not --remotes

List all commits in a Git repository.

Conclusion

To find more neat Git commands and hacks, browse the Git category. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.

git