[英]github merge rebase branch without conflicts
I have two sibling branches(from master branch) in which I am facing conflicts while merging both branches with master branch.我有两个兄弟分支(来自 master 分支),其中在将两个分支与 master 分支合并时遇到冲突。 I have to merge them with resolving conflicts(or merge conflict fix commit).
我必须将它们与解决冲突(或合并冲突修复提交)合并。
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 commit 1. init branch1 commits are 1. init(inherited of master) 2. commit1 branch2 commits are 1. init(inherited of master) 2. commit2
when I use git merge branch1
while on master branch.当我在 master 分支上使用
git merge branch1
时。 it works fine but then after I am running git merge branch2
where i get conflicts.它工作正常,但是在我运行
git merge branch2
,我遇到了冲突。 I need help in using git rebase to merge branch2
into master without adding further commits我需要帮助使用 git rebase 将
branch2
合并到 master 而不添加进一步的提交
o---o---o branch1
/
o---o---o---o---o---o---o master
\
o---o---o---o---o branch2
From master branch first merge branch1:从 master 分支首先合并 branch1:
git merge branch1
o---o---o branch1
/ \
o---o---o---o---o---o---o---o master
\
o---o---o---o---o branch2
Then rebase branch2 on master:然后在 master 上 rebase branch2:
git rebase master branch2
You will have some conflict:你会有一些冲突:
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".
Edit each conflict files to fix the conflict then编辑每个冲突文件以修复冲突然后
git add fileXXX
And和
git rebase --continue
You have now branch2 rebase on master你现在有 branch2 rebase on master
o---o---o branch1
/ \
o---o---o---o---o---o---o---o master
\
o'--o'--o'--o'--o' branch2
Now merge branch2 into master现在将 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.