【发布时间】:2015-05-13 09:19:54
【问题描述】:
我对我的仓库执行了某些操作。 (这实际上是尝试将 svn 分支与 git 同步,但为了这个问题,我们假设它们是未知的——正如 SO 指南所建议的那样,尽量保持最小化)。在那之后,我得到了一个不基于任何东西的分支broken_branch。只是一个没有任何父母的提交。
$ git lg
* 5757abc - (HEAD, origin/branches/broken_branch, broken_branch) ~ Some broken branch commit message (58 minutes ago) <AuthorName>
但是,我知道这个提交应该基于其他带有哈希的提交,比如来自master 分支的abc1234。所以,我尝试做一个合乎逻辑的事情,rebase:
$ git rebase abc1234
First, rewinding head to replay your work on top of it...
Applying: ~ Some broken branch commit message
Using index info to reconstruct a base tree...
<stdin>:829: trailing whitespace.
userData:
<stdin>:839: trailing whitespace.
userData:
<stdin>:849: trailing whitespace.
userData:
<stdin>:859: trailing whitespace.
userData:
<stdin>:869: trailing whitespace.
userData:
warning: squelched 204361 whitespace errors
warning: 204366 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging Path/To/File/Class.cs
CONFLICT (add/add): Merge conflict in Path/To/File/Class.cs
Failed to merge in the changes.
Patch failed at 0001 ~ Some broken branch commit message
The copy of the patch that failed is found in:
/Path/To/Project/.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".
其中Path/To/File/Class.cs 是在broken_branch 的单次提交中修改的文件。实际上,大约有 20 个文件被修改,每一个文件我都收到相同的消息。
(我已替换此问题中的所有字符串,以免意外泄漏任何内容,但我努力使所有内容保持一致)。
所以,我有这些问题:
- 我使用
git rebase解决此问题的决定是否正确?还是我应该使用其他东西? - 为什么会出现这些错误?我很肯定
broken_branch最初是在这个特定的提交上创建的(在 svn 中,但让我们将 svn 排除在问题的范围之外)。 - 我怎样才能解决这个变基来给我想要的结果?
【问题讨论】:
-
潜在编辑注意事项:我没有用
svn标记它,因为我试图尽量减少问题的上下文。我只提到svn来解释我是如何达到这种状态的(因为否则有人会问我),但为了这个问题应该是无关紧要的。 -
另外,我认为这个问题现在的标题很糟糕,但我想不出更好的标题。随意编辑它。
-
我会在从“已知”父亲创建的新分支上挑选破碎的银行提交。然后删除损坏的分支。
-
@BigMike 试过了;得到
error: could not apply 5757abc... ~ Some broken branch commit message与相同的合并冲突
标签: git git-branch git-rebase