git,

How to list all commits in a Git repository

Aug 22, 2022 · 1 min read · 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 log --oneline
git log --name-only
git reflog

Note(s): Needless to say, all of them include the git hash with a few dissimilarities. The main difference between git log and git reflog is that the latter shows the local history only, and it’s not being part of the repo itself (found under .git/logs/HEAD file).

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