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
TortoiseGit: What's the difference between "Git Sync", "Fetch" and "Pull"?
提问by smwikipedia
I am moving from TortoiseSvn to TortoiseGit. But enountered some unexpected difficulties.
我正在从 TortoiseSvn 迁移到 TortoiseGit。却遇到了一些意想不到的困难。
My working paradigm is as simple as:
我的工作范式很简单:
- Check out code
- Change some code
- Share with others for code review
- Commit changes
- 签出代码
- 更改一些代码
- 与他人共享以进行代码
- 提交更改
Why bother to have the 3 syntactically
similar commands below?
为什么要使用syntactically
下面的 3 个类似命令?
And Pull
and Fetch
even share the identical icon. What a user-friendly design!
而且Pull
和Fetch
甚至共享相同的图标。多么人性化的设计!
回答by Tomasz Madeyski
These are three different commands:
这是三个不同的命令:
- Git
pull
is a gitfetch
followed by gitmerge
- read here - Git
fetch
fetches info about remote repositories - read here - Git
sync
does everything in one command meaningpull
andpush
read here
If you want to compare git
and svn
workflow then git pull
is like svn update
. There's no direct svn
version of git fetch
. Git sync
is like svn up
&& svn commit
in one command
如果你想比较git
和svn
工作流程,那么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 fetch
operation 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 pull
is 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
是您将本地分支的远程版本更新为最新版本,同时更新其他远程跟踪分支的方法。