繁体   English   中英

github合并rebase分支没有冲突

[英]github merge rebase branch without conflicts

我有两个兄弟分支(来自 master 分支),其中在将两个分支与 master 分支合并时遇到冲突。 我必须将它们与解决冲突(或合并冲突修复提交)合并。

master commit 1. init branch1 commits are 1. init(inherited of master) 2. commit1 branch2 commits are 1. init(inherited of master) 2. commit2

当我在 master 分支上使用git merge branch1时。 它工作正常,但是在我运行git merge branch2 ,我遇到了冲突。 我需要帮助使用 git rebase 将branch2合并到 master 而不添加进一步的提交

                   o---o---o  branch1   
                  /
 o---o---o---o---o---o---o  master
                  \
                   o---o---o---o---o  branch2

从 master 分支首先合并 branch1:

git merge branch1
                   o---o---o  branch1   
                  /         \
 o---o---o---o---o---o---o---o  master
                  \
                   o---o---o---o---o  branch2

然后在 master 上 rebase branch2:

git rebase master branch2

你会有一些冲突:

First, rewinding head to replay your work on top of it...
Applying: branch2
Using index info to reconstruct a base tree...
M   fileXXX
Falling back to patching base and 3-way merge...
CONFLICT (content): Merge conflict in fileXXX

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

编辑每个冲突文件以修复冲突然后

git add fileXXX

git rebase --continue

你现在有 branch2 rebase on master

                   o---o---o  branch1   
                  /         \
 o---o---o---o---o---o---o---o  master
                              \
                               o'--o'--o'--o'--o'  branch2

现在将 branch2 合并到 master

git checkout master
git merge branch2
                   o---o---o  branch1   
                  /         \
 o---o---o---o---o---o---o---o---o'--o'--o'--o'--o'  master                               

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM