How to recover from git “deleted by us” conflict during rebase after file had been renamed (but git treated as a deletion)

时间秒杀一切 提交于 2021-02-15 07:55:13

问题


My git repo has 2 branches: 'develop' and 'feature'.

When I run git rebase develop, I see:

First, rewinding head to replay your work on top of it...
Applying: inital commit
Using index info to reconstruct a base tree...
A       datastore/static/js/app/main.js
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): datastore/static/js/app/main.js deleted in HEAD and modified in inital commit. Version inital commit of datastore/static/js/app/main.js left in tree.
error: Failed to merge in the changes.
Patch failed at 0001 inital commit
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".

I think this relates to the fact that an earlier commit on 'develop' moved datastore/static/js/app/main.js to assets/js/app/main.js, but because there were also changes within the file, git did not treat it as a "rename" but instead as a deletion of datastore/static/js/app/main.js and creation of new file assets/js/app/main.js.

What commands can I run to fix my situation?

I'm aware that git diff --base can show me some information that would help me manually fix my problem, but my intuition says that there is a cleaner, more automatic way (which is desirable since I will be dealing with many more than just 1 file conflict).

P.S. I also studied answers to these questions but still haven't figured out how to proceed:

  • Backport changes from renamed file
  • git merge conflict due to moved files

来源:https://stackoverflow.com/questions/63044843/how-to-recover-from-git-deleted-by-us-conflict-during-rebase-after-file-had-be

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!