Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git diff between current and head

Tags:

git

git-diff

I have two cloned versions of a repo (working copies) - say A and B. Now, in B, I made changes to file filename, committed and pushed. A is untouched. Now, before pulling in A, I want to see what new changes will a pull bring in.

I tried:

git diff
git diff HEAD
git diff HEAD:filename   filename

but none of them show the diffs (blank output). How to correctly view diff between local copy and head (I checked other answers, and my understanding of them is the above, but none of them seem to work).

Note: I have recently moved from svn to git. So the way I am thinking is: A & B are just copies of same "branch". Not sure if the understanding/terminology is correct.

like image 466
workwise Avatar asked Mar 18 '26 04:03

workwise


1 Answers

You need to fetch first, then you can look for the diffs:

cd A
git remote add B /path/to/B
git fetch B

git diff master B/master

You can see other diffs in "How can I see incoming commits in git?"


I have installed gitolite on a server. And there is a repo there, say ProjectXYZ.
Now, A and B are obtained on two different machines, using git clone user@reposerver:ProjectXYZ.git.

Then:

# on machine B
cd B/
git push -u origin master

# on machine A
cd A/
git fetch
git diff master origin/master
like image 86
VonC Avatar answered Mar 20 '26 17:03

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!