Hacker News new | ask | show | jobs
by codetrotter 2703 days ago
Git can show you the diff of any commit as well, though I guess maybe the interactivity you mentioned is important.

Anyhow, with just git.

Diff of most recent commit:

  git show HEAD
Diff of preceding commit:

  git show HEAD^
Diff of commit before that again

  git show HEAD^^
Of course you don’t want to type ^ 200 times. Fortunately you don’t have to. Diff of commit three steps back before most recent:

  git show HEAD~3
Or you can look at the log first

  git log
And find a specific commit and then use the first few characters of the id of that commit, e.g.

  git show af4c
And of course I would be remiss to not mention

  git diff
And

  git diff --cached
These two show you unstaged and staged changes before you commit. I use these commands all the time. So much that they are two of the commands I have created very short two-letter aliases for in my .bashrc

  alias di="git diff --cached"
  alias dp="git diff"
2 comments

Alternatively, you can use `tig` which allows you to browse the commit log, diffs, and blames interactively. It's a terminal ui tool.
I’m a noob on a new team with git (well versed on TFS though) thank you for posting this.