bemug
bemug

Reputation: 1784

Git diff between 2 different files on the same branch

I have 2 different files foo and bar.

Each one is on 2 different commits, on the same branch, respectively with SHA1 SHA1-foo and SHA1-bar. I want to see a diff between those 2 files.

I could checkout one of the files and copy it but maybe there's a better way.

Upvotes: 1

Views: 578

Answers (2)

Astrogat
Astrogat

Reputation: 1625

You can do:

git diff branch1:file branch2:file

Upvotes: 3

bemug
bemug

Reputation: 1784

I found that it works the same way as branches, see this SO thread.

git diff SHA1-foo:/path/to/foo SHA1-bar:/path/to/bar

Upvotes: 5

Related Questions