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

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

Difference between git pull . master vs git merge master

gitgit-merge

提问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 pullgives 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 . masterfetches 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.rebaseor branch.master.rebase.

git pull . master从当前存储库中获取(无操作),然后将做一些事情使当前分支与master. 这可能是一个合并,但它也可能是一个 rebase,具体取决于配置设置pull.rebasebranch.master.rebase.

In the case of a merge, the merge strategy my be affected by pull.twohead.

在合并的情况下,合并策略可能受pull.twohead.

git merge masterwill always merge master with the default merge strategy.

git merge master将始终将 master 与默认合并策略合并。

回答by Balog Pal

pullis a combination command, fetchfollowed 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 . masteris a correct syntaxes...

不确定句号git pull . master是正确的语法...