简体   繁体   English

Git Pull vs Git fetch哪一个优先?

[英]Git Pull vs Git fetch Which one is Preferable?

I know the difference between git pull and git fetch . 我知道git pullgit fetch之间的区别。

but i want to know, Which one is Preferable? 但我想知道,哪一个是优先考虑的?

because git pull doing merge automatically without my knowledge. 因为git pull在我不知情的情况下自动合并。 thats the different i found. 这就是我发现的不同。 git fetch wont do that. git fetch不会这样做。 is there anything else? 还有别的事吗?

Contrary to the above comments, git pull and git fetch are not completely different commands. 与上面的评论相反, git pullgit fetch 不是完全不同的命令。 Rather, doing a git pull on a given branch is the same as doing a git fetch followed by either merging or rebasing the current branch on its remote counterpart which was just updated. 相反,在给定分支上执行git pull与执行git fetch相同,然后在刚刚更新的远程对应项上合并或重新定义当前分支。

The utility of doing a git pull is that often the reason we fetch is to update a local branch with the version on the remote. 执行git pull的实用程序通常是我们获取的原因是使用远程版本更新本地分支。 So it is a bit of a convenience. 所以这有点方便。 We can always do fetch followed by merge separately. 我们总是可以执行fetch,然后单独合并。

git pull will do a git fetch and then a git merge . git pull将执行git fetch ,然后执行git merge So it depends what do you want to do. 所以这取决于你想做什么。

If you prefer to handle manually the merge you shouldn't use git pull 如果您更喜欢手动处理合并,则不应使用git pull

What is the difference between 'git pull' and 'git fetch'? 'git pull'和'git fetch'有什么区别?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM