Hacker News new | ask | show | jobs
by parennoob 3865 days ago
Let me attempt an explanation.

'git rev-list' will give you the SHA-1 hashes of all the commits reachable from a given commit. So 'git rev-list HEAD' is going to give you all commits reachable from HEAD, i.e. your latest one all the way to your first commit. After that, there's a bunch of ways you could filter that. For example, you could run 'git rev-list HEAD | tail -1' to get the hash of the first commit, and now all you need to do to show the whole diff is pipe it to 'xargs git show' (xargs reads from stdin and uses that as the argument to whatever comes after it.

The grandparent comment uses a slightly interesting trick – he/she used the built-in '--max-parents' filter. '--max-parents' limits the number of parent commits. For example, a merge has 2 or more parent commits, so the '--max-parents=1' option will exclude all merge commits. What commit has no parents? Why, the first commit of the repo, of course.

Hence, the command 'git rev-list --max-parents=0 HEAD | xargs git show'.