git pull 之间的区别。大师 vs git 合并大师
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17339091/
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
Difference between git pull . master vs git merge master
提问by Hotschke
Having no remote repository, just one local repository with two branches.
没有远程存储库,只有一个带有两个分支的本地存储库。
$ git branch -a
master
* devel
Are following commands in this contextthe same/synonym?
在此上下文中以下命令是否相同/同义词?
$ git pull . master
and
和
$ git merge master
UPDATE:
更新:
$ git help pull
gives following information
$ git help pull
提供以下信息
SYNOPSIS
git pull <options> <repository> <refspec>...
DESCRIPTION
...
Note that you can use . (current directory) as the <repository> to pull
from the local repository — this is useful when merging local branches
into the current branch.
I actually don't understand why this is useful as mentioned in this manpage.
我实际上不明白为什么这在本手册页中提到的很有用。
采纳答案by CB Bailey
git pull . master
fetches from the current repository (a no-op) and will then do something to bring the current branch up to date with master
. That something might be a merge but it might also be a rebase depending on the configuration setting pull.rebase
or branch.master.rebase
.
git pull . master
从当前存储库中获取(无操作),然后将做一些事情使当前分支与master
. 这可能是一个合并,但它也可能是一个 rebase,具体取决于配置设置pull.rebase
或branch.master.rebase
.
In the case of a merge, the merge strategy my be affected by pull.twohead
.
在合并的情况下,合并策略可能受pull.twohead
.
git merge master
will always merge master with the default merge strategy.
git merge master
将始终将 master 与默认合并策略合并。
回答by Balog Pal
pull
is a combination command, fetch
followed by merge
. With default or sensible params it will synchronize your current branch.
pull
是一个组合命令,fetch
后跟merge
. 使用默认或合理的参数,它将同步您当前的分支。
With the params as in question most of its work is sabotaged. the fetch part is overruled to use the current repo, so that is skipped, and you explicitly ask master overruling FETCH_HEAD.
使用有问题的参数,它的大部分工作都被破坏了。fetch 部分被否决以使用当前的 repo,因此被跳过,并且您明确要求 master 否决 FETCH_HEAD。
So in that form I believe they are identical (and I'd put the first in nonsense category too).
所以在这种形式中,我相信它们是相同的(我也会把第一个放在废话类别中)。
回答by radistao
the only difference - in second case (git merge master
) it will merge with not freshdata, but with data from your last remote update. So, if you just have made fetch
(or git remote update
) - they work the same way, but if you updated local repository a long time ago - it will merge with old snapshot.
唯一的区别 - 在第二种情况 ( git merge master
) 中,它不会与新数据合并,而是与上次远程更新的数据合并。因此,如果您刚刚制作fetch
(或git remote update
) - 它们的工作方式相同,但是如果您很久以前更新了本地存储库 - 它会与旧快照合并。
Not sure the period in git pull . master
is a correct syntaxes...
不确定句号git pull . master
是正确的语法...