Git merge 命令

标签 git

我正在阅读以下文章:http://github.com/guides/keeping-a-git-fork-in-sync-with-the-forked-repo ,他们提到通过创建以下别名同时从两个 repo 中提取更改:

pu = !"git fetch origin -v; git fetch wycats -v; git merge wycats/master"

这是有道理的,但是,作为 Git 的新手,我很好奇为什么命令是这样的,而不是:

pu = !"git fetch origin -v; git merge origin/master; git fetch wycats -v; git merge wycats/master"

或类似的东西。基本上,我想知道为什么 merge 的参数是 wycats/master 以及它如何自动知道 origin/master 。寻找快速解释。

最佳答案

我不知道为什么 Octopus merge 会在这里发生(DOS session 中的 msysgit1.6.5)。
一只 Octopus 与多个 parent merge 。

如果我按照“两次修改到远程仓库 pull 回”的套路,这是我在最终 merge 之前看到的(一轮 pull 后):

alt text

chgB(from main,即“origin”)和chgA(from remote“mainA”)已经一一 merge 在 master 中。

已进行并获取了另外两项更改:来自 origin 的 chgB2 和来自 mainAchgA2

如果我尝试只 merge mainA/master,我会得到:

alt text

chgA2 已 merge 。 chgB2 来自“main”(来源)的仍然卡在那里...

但是如果我尝试在 mainA 中再做一个更改,并在 merge 命令中指定两个远程存储库,则会发生 Octopus merge :

C:\Prog\Git\tests\octo\dest1>git merge origin/master mainA/master
Trying simple merge with 9e3e16d8e75cec3be621c47fb72e955cc2574f0f
Trying simple merge with 4dfb282a31d5bafddb244c84b66ede41e28f1042
Merge made by octopus.
 a.txt |    2 +-
 b.txt |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

alt text

关于Git merge 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2437409/

相关文章:

git - Git 标签只适用于当前分支吗?

linux - 从 GitHub 迁移到 GitLab(作为 POSIX 环境中的远程)

svn - 我可以在 svn repos 中使用 git repos

git - 远程跟踪 Git 中的当前分支

git - 如何修复此 git 网络图?

git - 使用 github 获取资源

git - OS X 10.10 : Errors in locating and using brew and Git

git - 让 Git 不跟踪所有分支

git - 在 git 中使克隆的存储库成为主存储库

java - 用于生产、阶段、测试和开发部署的 Bitbucket 主分支