user445658
user445658

Reputation: 116

Git vs SVN How to diff against tags

With svn and Cornerstone this is trivial, but I can't seem to find a way to do it with Git or sourcetree (Atlassians excellent visual git tool for mac sourcetreeapp).

I need to compare two commits on the same branch that are several versions apart. Cornerstone lets me pick any version or tag and compare against my working directory but I can't seem to find a way to get sourcetree, or with git diff and filemerge (opendiff) to do this.

E.g.

working dir HEAD
change three
change two
change one Tag: works

I need to compare HEAD and works but I can't seem to find a way to do this. I can't even check out a file from works like I can in SVN, it wants to pull the whole repository at that version and wipe out my working directory. If I could get the files side by side I could run opendiff or another tool.

What am I missing?

Upvotes: 0

Views: 1047

Answers (3)

Adam Dymitruk
Adam Dymitruk

Reputation: 129654

Run gitk --all

Select the first commit.

Right click the second commit and select "diff this to selected"

Or you can do that in the command line with git diff.

Upvotes: 0

Andy
Andy

Reputation: 46444

  1. You can compared any two commits with git diff <commit hash1> <commit hash2>.
  2. You can compare a single file in any two commits with git diff <commit hash1> <commit hash2> -- file/path
  3. You can also check out a file from a particular commit with git checkout <commit hash> -- file/path.

Note: You can substitute <commit hash> with any tag, branch, etc.

Upvotes: 2

Mike Kwan
Mike Kwan

Reputation: 24447

You can diff the tags like so:

git diff tag1 tag2

Upvotes: 0

Related Questions