TortoiseGit:“Git Sync”、“Fetch”和“Pull”有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35982610/
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-09 04:01:37  来源:igfitidea点击:

TortoiseGit: What's the difference between "Git Sync", "Fetch" and "Pull"?

gittortoisegit

提问by smwikipedia

I am moving from TortoiseSvn to TortoiseGit. But enountered some unexpected difficulties.

我正在从 TortoiseSvn 迁移到 TortoiseGit。却遇到了一些意想不到的困难。

My working paradigm is as simple as:

我的工作范式很简单:

  1. Check out code
  2. Change some code
  3. Share with others for code review
  4. Commit changes
  1. 签出代码
  2. 更改一些代码
  3. 与他人共享以进行代码
  4. 提交更改

Why bother to have the 3 syntacticallysimilar commands below?

为什么要使用syntactically下面的 3 个类似命令?

And Pulland Fetcheven share the identical icon. What a user-friendly design!

而且PullFetch甚至共享相同的图标。多么人性化的设计!

enter image description here

在此处输入图片说明

回答by Tomasz Madeyski

These are three different commands:

这是三个不同的命令:

  1. Git pullis a git fetchfollowed by git merge- read here
  2. Git fetchfetches info about remote repositories - read here
  3. Git syncdoes everything in one command meaning pulland pushread here
  1. Gitpull是一个 gitfetch后跟 git merge-在这里阅读
  2. Gitfetch获取有关远程存储库的信息 -在此处阅读
  3. Gitsync在一个命令中完成所有操作pullpush在此处阅读

If you want to compare gitand svnworkflow then git pullis like svn update. There's no direct svnversion of git fetch. Git syncis like svn up&& svn commitin one command

如果你想比较gitsvn工作流程,那么git pull就像svn update. 没有直接svn版本的 git fetch。Gitsync就像一个命令中的svn up&&svn commit

回答by Saurabh Oza

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes//.

您可以随时执行 git fetch 以更新 refs/remotes// 下的远程跟踪分支。

git fetchoperation never changes any of your own local branchesunder refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn't recommend doing this).

git fetch操作永远不会更改refs/heads 下您自己的任何本地分支,并且在不更改您的工作副本的情况下是安全的。我什至听说有人在后台的 cron 作业中定期运行 git fetch (尽管我不建议这样做)。

git pullis what you would do to bring a local branch up-to-date with its remoteversion, while also updating your other remote-tracking branches.

git pull是您将本地分支的远程版本更新为最新版本,同时更新其他远程跟踪分支的方法。