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:
1 |
269d73b1b64a0fe0afc092f02e6b84bffb3305bc |
You can also refer the commit ID using the first 7 character of the SHA-1, like:
1 |
269d73b |
Let’s say you want to revert your latest commit to one commit before yours, you can do
1 |
git checkout sha_1~x file/name |
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:
1 |
git diff xyz123~6 file/name |
Happy gitting :)
[1] http://en.wikipedia.org/wiki/Git_(software)#Data_structures