I'm a little confused about git fetch and comparing differences .
I have the following local branches;
In master branch I have a text file which I make changes to, commit and then push to the origin/master.
In another local repo (for test purposes) I have a remote to the same repo as above. I run
It displays no differences, but if i do git pull origin master
it pulls and merges the changes I made to the text file. I'm probably wrong but I thought a pull did a fetch and a merge, so doing a fetch allowed me to see the changes to the remote branch before merging them.
Why do you get no git diff output before adding? Git does not treat files in the filesystem as automatically included in the version control system. You have to add things explicitly into the Git repository (as you are doing by adding the current directory with git add . ).
git fetch git log --name-status origin/master.. Will show you what commits you are about to retrieve, along with the names of the files. Based upon this reply the command "git log --graph -p" is doing a nice job. It shows tree information about the history and code changes as well.
git fetch really only downloads new data from a remote repository - but it doesn't integrate any of this new data into your working files. Fetch is great for getting a fresh view on all the things that happened in a remote repository.
On its own, git fetch updates all the remote tracking branches in local repository. No changes are actually reflected on any of the local working branches.
What you need to do to perform a diff (after a fetch) in respect to the head of your branch and the origin at the same branch is a
git diff HEAD...origin
Please note the 3 dots. By the way, the question can possibly be considered a duplicate of this one, at least in terms of the accepted answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With