git rebase 冲突不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19445186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git rebase with conflict not work
提问by DenisOgr
I have remote repository. I do:
我有远程存储库。我愿意:
git clone https://[email protected]/mylogin/myrepo.git
Clone success.
I have git tree:
C(master)
| B:A
| /
B /
|
A
|
A0
|
A01(origin/head)(origin/master)
|
(some commits)
克隆成功。我有 git 树:
C(master)
| 乙:甲
| /
乙 /
|
一个
|
A0
|
A01(origin/head)(origin/master)
|
(一些提交)
I need:
B:A
C(master) /
我需要:
B:A
C(master) /
I need rebase branch B to C(master) What I do:
我需要将分支 B 重新设置为 C(master) 我做什么:
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
What must I do? I can switch in branch b1, resolve conflict and commit, but it not help (I tested it).
我必须做什么?我可以在分支 b1 中切换,解决冲突并提交,但没有帮助(我测试过)。
回答by micromoses
Git will stop rebasing if it detects conflicts it cannot automatically resolve. In your case, you have a conflict in the file index1.txt
(you can see it in the output, and later on as well when running git status
). You must fix the conflicts before continuing. Edit the file, and you'll see <<<<<<
, ======
and >>>>>>
markers. The conflict is in those lines, where what's between the <
and the =
is the changes in master, and after that (until the >
) is the changes in branch b1
. Fix it, remove the git markers (<
,=
,>
), then run git add index1.txt
, and move on to the next file (if you have any, in this example only index1.txt
conflicts). Once you're done adding all files, run git rebase --continue
. If git encounters another conflict, simply repeat the process for each file(s) it has problems with. Once you're done, git will tell you that rebase has successfully finished, and you'll be back on branch b1
. If you want to stop the process and return to the original b1
(before the rebase command), simply run git rebase --abort
.
如果 Git 检测到无法自动解决的冲突,它将停止变基。在您的情况下,您在文件中存在冲突index1.txt
(您可以在输出中看到它,稍后在运行时也可以看到git status
)。在继续之前,您必须解决冲突。编辑文件,您将看到<<<<<<
,======
和>>>>>>
标记。冲突就在那些行中,其中<
和之间=
是 master 中的更改,之后(直到>
)是 branch 中的更改b1
。修复它,删除 git 标记(<
, =
, >
),然后运行git add index1.txt
,然后移至下一个文件(如果有,在本例中仅index1.txt
发生冲突)。添加完所有文件后,运行git rebase --continue
. 如果 git 遇到另一个冲突,只需对它有问题的每个文件重复该过程。完成后,git 会告诉您 rebase 已成功完成,您将返回 branch b1
。如果您想停止进程并返回到原始状态b1
(在 rebase 命令之前),只需运行git rebase --abort
.
Remember that when you fix conflicts, don't edit the file to be as it should be in your final commit, rather only introduce the changes you wanted for that specific commit. Other changes will be added as git continues rebasing and applying your commits.
请记住,当您修复冲突时,不要将文件编辑为您最终提交时应有的样子,而应仅针对该特定提交引入您想要的更改。随着 git 继续 rebase 和应用您的提交,将添加其他更改。