【问题标题】:Git Rebase Reports Errors, But There's Nothing To FixGit Rebase 报告错误,但没有什么可修复的
【发布时间】:2015-08-26 22:43:24
【问题描述】:

我正在尝试在我的开发分支之上重新设置功能分支,但我收到以下错误。我不确定,但我认为每当我将文件从一个文件夹移动到另一个文件夹时都会发生这种情况。它抱怨的那些文件没有在我重新建立基础的分支中进行任何更改,所以我不确定问题是什么。这最初发生在 git 2.2.2 中;我刚刚尝试升级到 2.5.0,但它仍在发生。

如果我忘记了变基,只是将我的功能分支合并到开发分支中,那么一切正常。 Git 将功能分支与开发分支合并没有问题。

有人对我如何完成变基有任何建议吗?我尝试使用 git rebase --skip 选项,但这导致一堆代码(可能来自其他提交)被删除。

First, rewinding head to replay your work on top of it...
Applying: Entries now populate the Schedule A table when a calendar day is  clicked; other refactoring
Applying: Introduce DailyLog
Using index info to reconstruct a base tree...
<stdin>:37: trailing whitespace.
    @function_groups = current_user.organization.visible_function_groups
<stdin>:82: trailing whitespace.
    if @entry.save
<stdin>:111: trailing whitespace.
    # for a given day.
<stdin>:136: trailing whitespace.
    self.create(user: user, created_at: the_date_time, organization_id: user.organization.id,
<stdin>:383: trailing whitespace.
      </div>
warning: squelched 13 whitespace errors
warning: 18 lines add whitespace errors.
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    app/views/entries/_entry_form_activity.html.erb
    app/views/entries/_entry_form_employee_info.html.erb
    app/views/entries/_entry_form_other_info.html.erb
    app/views/entries/_entry_form_production_info.html.erb
    app/views/entries/_entry_form_time_codes.html.erb
    app/views/entries/create.js.erb
    app/views/entries/edit.html.erb
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0002 Introduce DailyLog
The copy of the patch that failed is found in:
    /home/slopeuser/Documents/dev/estat/.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 正在查找未提交的文件并且它们将丢失。
  • 是的,这对我来说也是错误的。通过git status 检查了开发和功能分支,并且没有未提交的更改。
  • 是的,但是您可以在 .gitignore 中拥有这些文件(我猜)您在 git status 中看不到它们,但它们存在。然后当 git 尝试创建这些文件时,它会报告错误。试试这个:用两个分支克隆你的仓库,然后在一个新的“干净”仓库中尝试 rebase。

标签: git


【解决方案1】:

看起来您可能有一些空白错误,您解决它的不同之处可能是忽略空白,尝试为您使用的不同找到“显示空白”设置。

您可以尝试通过修改空白设置让 git 处理该问题,请参阅此处了解类似问题: git, whitespace errors, squelching and autocrlf, the definitive answers

【讨论】:

  • 我不认为这是问题所在。我查看了您的链接并添加了一个配置选项来解决空白问题。 Git 现在修复空白问题,但它仍然失败。我认为这是更重要的行error: Your local changes to the following files would be overwritten by merge: rebase 似乎不喜欢开发分支想要重新引入在功能分支中移动的文件这一事实。
【解决方案2】:

我仍然不确定变基失败的原因,但我认为在查看 rebase documentation 后我可能找到了解决方法。事实证明,您可以通过 -s 选项将合并策略传递给 rebase 命令。

我通过执行以下操作取消了当前失败的 rebase:

git rebase --abort

然后使用不同的合并策略重新运行 rebase:

git rebase develop -s resolve

这次所有提交都按预期重新设置。

【讨论】:

    猜你喜欢
    • 2016-10-27
    • 2015-03-21
    • 2020-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    • 2011-09-11
    相关资源
    最近更新 更多