git,

How to list all commits in a Git repository

Aug 22, 2022 · 1 min read · 25 views · Post a comment

Another potentially neat Git command to share. This time we are going to see how to list commits in a Git repository. This could be useful when writing scripts or from a personal experience in a CI/CD scenario with a bit of text processing.

Prerequisites

  • Git

Solution

Step 1. The command we are looking for is git log, although there are few variations you could try depending on the output you are looking for. You could try each of them though.

git log
git reflog
git log --oneline
git log --name-only

Needless to say, all of them include the git hash with a few minor dissimilarities. The one that I’m using mostly on daily basis is git log --name-only.

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