Difference between git pull . master vs git merge master

橙三吉。 提交于 2020-01-12 02:55:06

问题


Having no remote repository, just one local repository with two branches.

$ git branch -a
  master
* devel

Are following commands in this context the same/synonym?

$ git pull . master

and

$ git merge master

UPDATE:

$ git help pull gives following information

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.


回答1:


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.

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

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




回答2:


pull is a combination command, fetch followed by merge. With default or sensible params it will synchronize your current branch.

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.

So in that form I believe they are identical (and I'd put the first in nonsense category too).




回答3:


the only difference - in second case (git merge master) it will merge with not fresh data, 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.

Not sure the period in git pull . master is a correct syntaxes...



来源:https://stackoverflow.com/questions/17339091/difference-between-git-pull-master-vs-git-merge-master

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!