git tip #1: commit ID SHA-1

Software repository uses a unique ID to define a commit (revision). CSV or SVN use a incremental number as an ID. But in git the commit ID is the SHA-1 of the change set [1]. The question now will be, how to check out, revert or diff latest changes to some past commit?

Commit ID in git looks like this:

You can also refer the commit ID using the first 7 character of the SHA-1, like:

Let’s say you want to revert your latest commit to one commit before yours, you can do

where sha_1 is your current commit ID and x is how many commits you want to go back.

So if you want to make a diff from your current file to a file which is 6 commits back:

Happy gitting :)


Leave a Reply

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