How to list all commits in a git repository

`git log` only list all the commits in the current working branch. For some cases, we may want to list all the commits in a git repository. The `git log` command does not do this. But there are other supports in `git` that can do so.

The command to list all commits is

git rev-list --remotes

`git rev-list` list commit objects in reverse chronological order. The key option is `–remotes`. When the option is specified and left empty, it pretends as if all the refs in `refs/remotes` are listed on the command line.

So “all the refs in `refs/remotes`” plays the trick here!

You may also use `–pretty` to make the output look better with more information and commits messages.

git rev-list --all --remotes --pretty

Leave a Reply

Your email address will not be published. Required fields are marked *