git merge origin/master 有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11130292/
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
what does git merge origin/master do?
提问by Adam Lee
After fetching from remote using git fetch
, we need to use something like
从远程 using 获取后git fetch
,我们需要使用类似的东西
git merge origin/master
I would like to know if this command also does git commit
at the same time? Is the order origin/master
important? Can I write master/original
?
我想知道这个命令是否也git commit
同时执行?顺序origin/master
重要吗?我可以写master/original
吗?
回答by Matt Enright
git merge origin/master
can do one of two things (or error).
git merge origin/master
可以做两件事之一(或错误)。
In the first case, it creates a new commit that has two parents: the current HEAD
, and the commit pointed to by the ref origin/master
(unless you're doing something funny, this is likely to be (the local pointer to) the branch named master
on a remote named origin
, though this is completely conventional).
在第一种情况下,它创建一个具有两个父项的新提交:当前HEAD
和 ref 指向的提交origin/master
(除非您正在做一些有趣的事情,否则这很可能是(指向)名为master
on的分支的(本地指针)一个名为 的遥控器origin
,尽管这是完全传统的)。
In the second case, where there is no tree-level merge necessary, rather than creating a new commit, it updates the currently checked-out ref to point to the same commit as is pointed to by origin/master
. (This is called a fast-forwardmerge -- git can be directed to either always or never do this when you merge through command-line flags).
在第二种情况下,不需要树级合并,而不是创建新提交,它更新当前检出的 ref 以指向与 指向的相同提交origin/master
。(这称为快进合并——当您通过命令行标志合并时,可以将 git 定向到始终或从不执行此操作)。
It does not call git commit
directly, which is a higher-level (porcelainin the git-parlance) command intended for users.
它不git commit
直接调用,这是一个面向用户的更高级别(git-parlance 中的瓷器)命令。
Calling git merge master/original
will try and resolve master/original
to a commit, which will almost certainly (again, unless you've done something deliberate) notbe the same as origin/master
. If you happen to have a remote named master
that has a branch named original
, it will create a new commit which has that as the second parent.
调用git merge master/original
将尝试解决master/original
的承诺,这将几乎肯定(同样,除非你已经做了一些研讨)不相同的origin/master
。如果你碰巧有一个远程命名master
,有一个名为分支original
,它会创建一个新的提交其具有作为第二父。
You may find git help rev-parse
to be helpful in deciphering how git attempts to resolve ref names or other notations into commits.
您可能会发现git help rev-parse
这有助于解读 git 如何尝试将引用名称或其他符号解析为提交。
回答by Jarryd
What this does is merges the branch referred to as origin/master into your current branch. The order is veryimportant. The word originmeans the place from which you cloned your repository, i.e., the origin of the repository, the word masteris just a branch name, however master is usually used as the main branch, or the trunkbranch as some other systems call it.
这样做是将称为 origin/master 的分支合并到您当前的分支中。顺序非常重要。origin这个词表示你克隆仓库的地方,即仓库的起源,master这个词只是一个分支名称,但是master通常用作主分支,或者其他一些系统称之为主干分支.
Merge might need to do a commit depending on the state of your development. If your history hasn't diverged from the origin, it can do what is called a fast-forward---all that needs to be done is put the new history on top of yours. If your development has diverged from the origin then if the merge can be done with no conflicts then the merge is done and a new commit is recorded at HEAD to specify the merge and the two parents.
Merge 可能需要根据您的开发状态进行提交。如果你的历史没有偏离原点,它可以做所谓的快进——所有需要做的就是把新的历史放在你的上面。如果您的开发已经偏离原点,那么如果可以在没有冲突的情况下完成合并,则合并完成,并在 HEAD 记录新提交以指定合并和两个父项。
Furthermore, if merging can't be done because of a conflict, your working copy is updated to reflect the fact that there are conflicts, then when you fix them, you manually make the commit that records the merge.
此外,如果由于冲突而无法进行合并,则会更新您的工作副本以反映存在冲突的事实,然后在修复它们时,手动进行记录合并的提交。