git rebase与冲突不起作用

Den*_*Ogr 11 git rebase

我有远程存储库.我做:

git clone https://mylogin@bitbucket.org/mylogin/myrepo.git
Run Code Online (Sandbox Code Playgroud)

克隆成功.我有git tree:
C(master)
| B:A
|/
B/
|
A
|
A0
|
A01(原点/头)(原点/主)
|
(一些提交)

我需要:
                B:A
C(主人)/ 

我需要rebase分支B到C(主)我做什么:

git checkout b1
Switched to branch 'b1'
git rebase master
First, rewinding head to replay your work on top of it...
Applying: B:A
Using index info to reconstruct a base tree...
M   index1.txt
Falling back to patching base and 3-way merge...
Auto-merging index1.txt
CONFLICT (content): Merge conflict in index1.txt
Failed to merge in the changes.
Patch failed at 0001 B:A
The copy of the patch that failed is found in:
   /pth/to dir/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

git branch
* (no branch)
  b1
  master
Run Code Online (Sandbox Code Playgroud)

我必须做什么?我可以切换分支b1,解决冲突和提交,但它没有帮助(我测试了它).

mic*_*ses 28

如果Git检测到无法自动解决的冲突,它将停止变基.在您的情况下,文件中存在冲突index1.txt(您可以在输出中看到它,稍后也可以在运行时看到它git status).您必须在继续之前修复冲突.编辑文件,你会看到<<<<<<,======>>>>>>标记.冲突在这些行中,其中<和之间的=变化是主变化,之后(直到>)是分支中的变化b1.修复它,删除git的标记(<,=,>),然后运行git add index1.txt,并移动到下一个文件(如果您有什么,在这个例子中仅index1.txt冲突).完成添加所有文件后,运行git rebase --continue.如果git遇到另一个冲突,只需为它遇到问题的每个文件重复该过程.一旦你完成了,git会告诉你rebase已经成功完成,你将回到分支机构b1.如果要停止进程并返回原始进程b1(在rebase命令之前),只需运行即可git rebase --abort.

请记住,在修复冲突时,不要将文件编辑为最终提交时应该存在的文件,而只是引入您对特定提交所需的更改.随着git继续重新定位和应用您的提交,将添加其他更改.

  • 请注意,您应该编辑带有冲突的文件(在您的情况下为`index1.txt`),而不是`patch`文件.如果你不确定正在改变什么样的变化,那么`patch`就可以参考了. (2认同)