I would like to do a diff between two tags and committed changes between those two tags. Could you please tell me the command?
4 Answers
$ git diff tag1 tag2
or show log between them:
$ git log tag1..tag2
sometimes it may be convenient to see only the list of files that were changed:
$ git diff tag1 tag2 --stat
and then look at the differences for some particular file:
$ git diff tag1 tag2 -- some/file/name
A tag is only a reference to the latest commit 'on that tag', so that you are doing a diff on the commits between them.
(Make sure to do git pull --tags first)
Also, a good reference: https://git-scm.com/docs/git-diff
- 1,671
- 1
- 15
- 30
- 15,385
- 4
- 27
- 33
-
2@kaiser lol! btw, I would like to add this tip to compare whole directories from within `git gui` at "tools/add" like `git difftool -d $REVISION`! and to link [this answer](http://stackoverflow.com/a/2006241/1422630) too – Aquarius Power Jun 20 '14 at 06:09
-
Is there a way to make the `git log` command only show additional commits, not shared commits? – CMCDragonkai Dec 28 '15 at 08:48
-
@CMCDragonkai that is what this command does, it shows the additional commits on tag2 since tag1. – gauteh Dec 28 '15 at 16:27
-
In my use, it showed all shared commits and additional commits without any distinction between the 2. – CMCDragonkai Dec 29 '15 at 04:32
-
@CMCDragonkai: perhaps you are looking for the `--cherry` argument. – gauteh Jan 15 '16 at 14:38
-
2Also useful: simply `git diff tag1` gives differences between tag1 and working directory; `git diff tag1 HEAD` differences between tag1 and most recent commit. – ChrisV Mar 24 '16 at 15:59
-
And: `gitk` (or `gitg`) makes browsing commits between tags easy. – ChrisV Mar 24 '16 at 16:08
-
`git diff tag1 tag2 --stat=1000` by adding `=1000` you allow the file names to show in their entirety – jsgoupil Oct 13 '20 at 16:30
-
amazing how intuitive git commands are (at least some of them :)) – Jean-François Fabre Jan 27 '21 at 13:50
-
if you want to just see the list of files changed its `--name-only` before the two – Ridhwaan Shakeel Apr 25 '21 at 02:59
If source code is on Github, you can use their comparing tool: https://help.github.com/articles/comparing-commits-across-time/
- 33,683
- 14
- 104
- 137
-
is there any way to do this without the 250 commit limit? – TheTechRobo Stands for Ukraine Dec 28 '20 at 15:35
For a side-by-side visual representation, I use git difftool with openDiff set to the default viewer.
Example usage:
git difftool tags/<FIRST TAG> tags/<SECOND TAG>
If you are only interested in a specific file, you can use:
git difftool tags/<FIRST TAG>:<FILE PATH> tags/<SECOND TAG>:<FILE PATH>
As a side-note, the tags/<TAG>s can be replaced with <BRANCH>es if you are interested in diffing branches.
- 4,194
- 1
- 39
- 45
As @Nakilon said, their is a comparing tool built in github if that's what you use.
To use it, append the url of the repo with "/compare".
- 2,609
- 1
- 9
- 24
-
1is there any way to do this without the 250 commit limit? – TheTechRobo Stands for Ukraine Dec 28 '20 at 15:34