How to see the changes in a commit?
When I do
git diff COMMIT I see the changes between that commit and HEAD (afaik) but I would like to see the changes that were made by that single commit.
I haven’t found any obvious options on diff/log that will give me that output.
13 Solutions collect form web for “How to see the changes in a commit?”
To see the diff for a particular
git diff COMMIT^ COMMIT will show you the difference between that
COMMIT‘s ancestor and the
COMMIT. See the man pages for git diff for details about the command and gitrevisions about the
^ notation and its friends.
git show COMMIT will do something very similar. (The commit’s data, including its diff.) See the git show manpage.
As mentioned in “Shorthand for diff of git commit with its parent?”, you can also use
git diff with:
git diff COMMIT^!
git diff-tree -p COMMIT
With git show, you would need (in order to focus on diff alone) to do:
git show --color --pretty=format:%b $COMMIT
COMMIT parameter is a commit-ish:
A commit object or an object that can be recursively dereferenced to a commit object. The following are all commit-ishes: a commit object, a tag object that points to a commit object, a tag object that points to a tag object that points to a commit object, etc.
See gitrevision “SPECIFYING REVISIONS” to reference a commit-ish.
See also “What does tree-ish mean in Git?”.
You can also try this easy way:
git show <COMMIT>
git show shows the changes made in the most recent commit.
git show HEAD.
git show HEAD~1 takes you back 1 commit.
From the man page for git-diff(1):
git diff [options] [<commit>] [--] [<path>…] git diff [options] --cached [<commit>] [--] [<path>…] git diff [options] <commit> <commit> [--] [<path>…] git diff [options] <blob> <blob> git diff [options] [--no-index] [--] <path> <path>
Use the 3rd one in the middle:
git diff [options] <parent-commit> <commit>
Also from the same man page, at the bottom, in the Examples section:
$ git diff HEAD^ HEAD <3>
Compare the version before the last commit and the last commit.
Admittedly it’s worded a little confusingly, it would be less confusing as
Compare the most recent commit with the commit before it.
this seems to do the job; i use it to show what has been brought in by a merge.
git whatchanged -m -n 1 -p <sha of merge commit>
git log -p COMMIT -1
git difftool COMMIT^ <commit hash>
is also possible if you have configured your difftool.
See here how to configure difftool
Or the manual page here
Additionally you can use
git diff-tree --no-commit-id --name-only -r <commit hash> to see which files been changed/committed in a give commit hash
To see author and time by commit use
git show COMMIT. Which will result in something like this:
commit 13414df70354678b1b9304ebe4b6d204810f867e Merge: a2a2894 3a1ba8f Author: You <email@example.com> Date: Fri Jul 24 17:46:42 2015 -0700 Merge remote-tracking branch 'origin/your-feature'
If you want to see which files had been changed, run the following with the values from the Merge line above
git diff --stat a2a2894 3a1ba8f.
If you want to see the actual diff, run
git --stat a2a2894 3a1ba8f
you could use
git diff HEAD HEAD^1 to see the diff with the parent commit.
if you only wanna see the list of files, add the option
--stat into it.
I’m running git version 2.6.1.windows.1 on Windows 10, so I needed a slight modification to Nevik’s answer (tilde instead of caret):
git diff COMMIT~ COMMIT
Other option is to quote the caret:
git diff "COMMIT^" COMMIT
this command will get you the git parent commit-hash
git log -n 2 <commit-hash>
git diff-tool <commit-hash> <parent-commit-hash>
bonnie@bonnie ~/ $ git log -n 2 7f65b9a9d3820525766fcba285b3c678e889fe3 commit 7f65b9a9d3820525766fcba285b3c678e889fe3b Author: souparno <firstname.lastname@example.org> Date: Mon Jul 25 13:17:07 2016 +0530 css changed to maintain the aspect ratio of the channel logos and to fit them properly commit c3a61f17e14e2b80cf64b172a45f1b4826ee291f Author: souparno <email@example.com> Date: Mon Jul 25 11:28:09 2016 +0530 the ratio of the height to width of the channel images are maintained
git difftool 7f65b9a9d3820525766fcba285b3c678e889fe3b c3a61f17e14e2b80cf64b172a45f1b4826ee291f
first get commit id using ,
git log #to list all
git log -p -1 #last one commit id
copy commit id.
now we use 2 methods to list changes from specific commit,
git diff commit_id^! #commit id something like this 1c6a6000asad012
git show commit_id eg: git show 1c6a600a