Reputation: 1402
How can I compare my most recent commit with the previous commit?
I'd like to know the diff between 83a853349d91c855442c
and 35ad2211a1cc7d0dbd49
(without having to specify the actual commit sha)
$ git log
commit 83a853349d91c855442c
Author: Jagat<[email protected]>
Date: Thu Aug 22 11:44:27 2019 -0700
Most recent commit
commit 35ad2211a1cc7d0dbd49
Author: Jagat<[email protected]>
Date: Thu Aug 22 09:35:12 2019 -0700
fix compilation
Upvotes: 0
Views: 135
Reputation: 2063
You can use a bare git show
for the most recent commit. From the docs:
For commits it shows the log message and textual diff. It also presents the merge commit in a special format as produced by git diff-tree --cc.
Upvotes: 2
Reputation: 26196
You need two things:
HEAD
. In your example, 83a853349d91c855442c
.<rev>^
(if there are multiple parent commits, use <rev>^<n>
to point to the n
-th parent). In your example, HEAD^
points to 35ad2211a1cc7d0dbd49
.Therefore:
git diff HEAD^ HEAD
Upvotes: 0
Reputation: 1402
git diff HEAD~1 HEAD
HEAD~1 is the penultimate commit (1 is the index), while HEAD refers to the most recent committed state.
Upvotes: 0