【问题标题】:Git rebase causing conflict with .idea files that no longer existGit rebase 导致与不再存在的 .idea 文件发生冲突
【发布时间】:2020-04-15 18:28:46
【问题描述】:

我在自己的分支上,在提交 5 或 6 次之前我遇到了这个问题

First, rewinding head to replay your work on top of it...
Applying: commit x
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: The following untracked working tree files would be overwritten by merge:
        .idea/.gitignore
        .idea/credit-policy-runs.iml
        .idea/dataSources.xml
        .idea/misc.xml
        .idea/modules.xml
        .idea/vcs.xml
Please move or remove them before you merge.
Aborting
error: Failed to merge in the changes.
Patch failed at 0001 commit x
hint: Use 'git am --show-current-patch' to see the failed patch

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 rm 和 git rebase --continue 时,我不久前遇到了类似的问题,但我认为我已经解决了,显然我只是推迟了它。

更新:当我删除 vim .idea/.gitignore 时,有一个文件,但是当我运行 git rm .idea/.gitignore 时,我遇到了致命错误:pathspec '.idea/.gitignore' 与文件不匹配

更新:当我尝试使用 -Xtheirs 运行变基时,出现这些错误

CONFLICT (modify/delete): Runs.avpr deleted in origin/develop and modified in HEAD~63. Version HEAD~63 of Runs.avpr left in tree.
CONFLICT (modify/delete): .idea/misc.xml deleted in origin/develop and modified in HEAD~63. Version HEAD~63 of .idea/misc.xml left in tree at .idea/misc.xml~HEAD~63.

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 github rebase


【解决方案1】:
git stash
git pull origin master --rebase

如果发生冲突,解决冲突并

git add .
git rebase --continue

重复直到你得到消息倒带......

git stash pop

【讨论】:

  • 问题是我无法修复冲突,并且没有本地更改存储
【解决方案2】:

据我所见,您的分支上没有跟踪文件(很好......不应跟踪 IDE 元数据文件)......但是在 other 分支上,文件是跟踪....这可能是不正确的。去看看为什么/何时将文件添加到该分支并将它们从分支中删除(有大量配方可以从分支的历史记录中删除文件),然后当您尝试合并时不会发生这种情况。

How can I delete a file from a Git repository?

【讨论】:

  • 这是一个变基。很可能包含文件的提交是操作自己的提交。
  • 哦!所以它发生在git rebase 对另一个分支进行结帐之前......无论哪种方式,问题都在另一个分支的历史记录中。
  • @eftshift0 提交是我的,你可以考虑另一个分支master(因为它是)并且它是空的
  • 这让我不确定如何删除它们,因为它们只是一个较旧的提交,出于某种原因添加了这些文件并在之后继续忽略它们。
【解决方案3】:

对于遇到这种情况的人,我找不到解决方案,而是将整个目录复制到临时目录中,创建了一个新分支,并将其从临时目录移动到新分支。非常残酷,并且丢失了所有提交历史记录,但这是我唯一能弄清楚的。

【讨论】:

    【解决方案4】:

    按照步骤解决问题

    1. 从您的项目中获取备份文件
    2. git checkout master
    3. git branch -d "你的分支名称"
    4. git pull origin master
    5. git branch "你的分支名称" 然后 git checkout "你的分支名称"
    6. 从备份中复制修改后的文件并粘贴到项目文件夹中
    7. 如果 git rm 不起作用,则使用删除 git rm --cached -r .idea(对于 Windows:“DEL /S /Q .idea”使用而不是“git rm --cached -r .idea”)

      终于推送你的代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-18
      • 1970-01-01
      • 2011-12-19
      • 1970-01-01
      • 2018-10-14
      相关资源
      最近更新 更多