4

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. git@github.com: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!

4

3 回答 3

6

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'?

于 2012-05-28T19:00:40.587 回答
6

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.

于 2012-05-28T20:24:30.847 回答
0

Generally, pull = fetch + merge. Sometimes, you may not see any changes after "fetch". You have to use "pull" to see the real updates. I don't know the root cause.

于 2017-09-18T07:18:08.420 回答