Home » Source Code Management ( SCM ) » Git » Git Log – List all the commit Id in reverse order

Git Log – List all the commit Id in reverse order

We have seen in our previous post “Git Log – Show Commit Messages in Reverse Order” using command “git log –reverse” , how we can show all the commit messages in reverse order, but there are times when we are not interested in everything by default is shown by “git log” command, but instead want to get only the commit Id’s from those and save those for some further processing.

In this post, we will show how you can list only the commit ids in forward and reverse order.

Display Git Commit Id’s with most recent commit id on top from your current branch

$ git rev-list HEAD

Here, 3 is most recent commit id, then 2 and 1 is very first commit id in this git repository.

Reverse the commit Id’s with most older commit id on top

$ git rev-list --reverse HEAD

Now, if you compare the above two images, you can easily see the commit ids are reversed between this two images.

You can save this commit ids in text file using below command if you need those for some purpose.

$ git rev-list --reverse HEAD > reverse_commit_ids.txt

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment