Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't see differences in remote branch after a git fetch

Tags:

git

I'm a little confused about git fetch and comparing differences .

I have the following local branches;

  • master
  • remote/origin/master

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

  • git fetch origin master
  • git diff master origin/master

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.

like image 213
screenm0nkey Avatar asked Sep 30 '11 10:09

screenm0nkey


People also ask

Why is git diff not showing?

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 . ).

How do I see new changes after git pull?

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.

Does git fetch affect remote?

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.

Does git fetch update all branches?

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.


1 Answers

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.

like image 193
Luca Geretti Avatar answered Oct 23 '22 03:10

Luca Geretti