With git, how do I see the changes in my last commit?
I mean I want to see a diff between my last commit and the commit previous to it. I know that I can see it on Github browser but I want to see this on terminal on my local commit history.
I know that I can do git diff between commits. So, I can do git diff oldCommit...HEAD to see the changes. But is there a command which can prevent me from having to copy oldCommit from git log which is cumbersome?
There are a few ways to see that, but the simplest is probably just:
git show
The git show command displays a formatted version of an object it git's database. Without any arguments, it shows HEAD - the currently checked out commit.
For a commit, its default output is the commit message and a diff to that commit's first parent - you can tweak that with the --format option.
Your most recent commit is HEAD, also known as @. The commit before anything is that thing suffixed with ~1 or simply ~. So you could say
git diff @~ @
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With