簡體   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