Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git fetch says "success" but nothing is downloaded

Tags:

git

github

I'm having some serious issues with git, and couldn't find any solutions online. I'm a new user, so I may be doing something wrong...

I have a repository hosted on Github, and someone on my team just pushed a new commit. Using Git GUI on windows, I attempted to fetch the new commit from Github. Git said that the fetch was a success, but no changes were found/downloaded.

I attempted to create a new remote to Github and used that instead. (e.g. [email protected]:MyUserName/MyProject). When fetching from this remote, Git says success and lists every branch as being newly updated. However, none of the branches get downloaded. If I run fetch again, the same message is displayed.

I had this same problem a couple days ago with the same repository. I 'fixed' it by deleting my local repository and cloning the repo from Github. But apparently it was only a temporary fix, as the problem is back again.

Any guidance is much appreciated!

SOLVED: You were right, I needed to merge after fetching the changes. (Sadly, Git GUI does not allow for pulling) I'm assuming that Git GUI used to do this automatically, but perhaps I accidentally changed the options at some point. Thanks for all the information!

like image 897
Maythe Avatar asked Dec 16 '22 23:12

Maythe


2 Answers

As the other answer says, fetch just gets the new commits into your history but updates only the "remote tracking branches". These are references to the new commits but are not local branches that you work on.

If you want to update your local branch with what the remote tracking branch will have, you want to use git pull.

I would advise that it is better to git fetch instead of git pull and then inspect what has changed on the remote branch with git log --all or gitk --all or some other way of inspecting the history. When you are aware of what changes you will be bringing in and their nature, you can now git merge origin/some-branch or git rebase origin/some-branch to update a local branch to include the changes.

like image 118
Adam Dymitruk Avatar answered Dec 19 '22 08:12

Adam Dymitruk


fetch does exactly what is happening in your case: it pulls down changes into your local Git (sync down the repositories), but does not merge those changes into your branches and does not update your working copy. I believe the verb you're looking for is pull.

What is the difference between 'git pull' and 'git fetch'?

like image 31
Matt Avatar answered Dec 19 '22 07:12

Matt