Git获取说“成功”但没有下载 [英] Git fetch says "success" but nothing is downloaded
问题描述
我在使用git时遇到了一些严重问题,并且无法在线找到任何解决方案。我是一个新用户,所以我可能做错了什么......
我有一个托管在Github上的存储库,并且我的团队中有人推送了一个新的提交。在Windows上使用Git GUI,我试图从Github获取新的提交。 Git表示取回是成功的,但没有发现/下载更改。
我试图为Github创建一个新的远程并使用它。 (例如git@github.com:MyUserName / MyProject)。从这个远程获取时,Git表示成功并将每个分支列为最新更新。但是,没有任何分支被下载。如果我再次运行提取,则会显示相同的消息。
几天前,我在同一个存储库中遇到了同样的问题。我通过删除我的本地存储库并从Github克隆回购来修复它。但显然这只是一个临时的解决方案,因为问题又回来了。
任何指导都非常感谢!
<解决方法:您说得对,我需要在获取更改后合并。 (可惜的是,Git GUI不允许拉)我假设Git GUI自动执行此操作,但也许我在某个时候意外地更改了这些选项。感谢所有的信息!
正如其他答案所述, fetch
只需将新提交进入历史记录,但只更新远程跟踪分支。这些是对新提交的引用,但不是您工作的本地分支。
如果要使用远程跟踪分支的内容更新本地分支,想要使用 git pull
。
我会建议最好 git fetch
而不是 git pull
,然后用 git log --all $ c>来检查远程分支上发生了什么变化$ c>或
gitk --all
或其他一些检查历史记录的方式。当你意识到你将会引入什么变化和它们的性质时,你现在可以 git rebase origin /某些分支
更新本地分支以包含更改。
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!
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.
这篇关于Git获取说“成功”但没有下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!