“git remote update”、“git fetch”和“git pull”有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17712468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:35:25  来源:igfitidea点击:

What is the difference between 'git remote update', 'git fetch' and 'git pull'?

git

提问by Davi Garcia

I'm starting to play with Git now and I'm a little bit confused. For me, looks like there are a lot of options to do the same thing. My question for now is what is the difference between the commands below:

我现在开始玩 Git,但我有点困惑。对我来说,看起来有很多选择可以做同样的事情。我现在的问题是以下命令之间的区别是什么:

  • git remote update
  • git fetch
  • git pull
  • git远程更新
  • 混帐

Also which one is more applicable for update a local copy of a remote branch?

另外哪个更适用于更新远程分支的本地副本?

回答by Makoto

git remote updatewill update all of your branches set to track remote ones, but not merge any changes in.

git remote update将更新您设置的所有分支以跟踪远程分支,但不会合并任何更改。

git fetchwill update only the branch you're on, but not merge any changes in.

git fetch将仅更新您所在的分支,但不会合并任何更改。

git pullwill update andmerge any remote changes of the current branch you're on. This would be the one you use to update a local branch.

git pull将更新合并您所在的当前分支的任何远程更改。这将是您用来更新本地分支的方法。

回答by LucasA

Not sure about the git remote update, but git pull is the git fetch followed automatically by a git merge...

不确定 git 远程更新,但 git pull 是 git fetch 后跟自动 git merge ...

This is partially a duplicate. Check: What is the difference between 'git pull' and 'git fetch'?

这部分是重复的。检查: “git pull”和“git fetch”有什么区别?

Also, if it means anything to you, I've never used git remote update neither fgit fetch. You can do just fine with pull, commit and push.

另外,如果这对你来说意味着什么,我从来没有使用过 git remote update 和 fgit fetch。你可以用 pull、commit 和 push 做的很好。

Hope it helps..

希望能帮助到你..