Reputation: 48416
If I've done git commit --amend several times on the same commit, is there a way I can list all of the different amendments to a given commit?
Upvotes: 17
Views: 8579
Reputation: 261
Actually the way exists. You can use the command git reflog
$ git reflog
d7f7f15 HEAD@{0}: commit (amend): My second commit
f5d2ed5 HEAD@{1}: commit (amend): My second commit
7333d86 HEAD@{2}: commit: My second commit
addbfef HEAD@{3}: commit: This was my first commit
When I use the pugin EGIT in the IDE Eclipse I can see the full list of commits and amendments, and the differences between them. I don't know how to see the differences by command line, if someone know how to do it, please post it.
Upvotes: 26
Reputation: 387677
git commit --amend
rewrites the commit completely, creating a new commit object and ultimately throwing the old one away. If there are references to the old object it is kept, so you could look up the changes; but in general this will probably not the case.
So the short answer is: No. Amending commits will rewrite the original commit to explicitely not have separated history. If you want to identify the different states, you should just make real commits.
If you just want this during your (personal/private) development, you can also make normal commits and then later squash the commits to create a single one if you want to clean it up.
Upvotes: -2