Search code examples
gitgit-rebase

How can I restore a deleted file in a complex git rebase?


I'm in the middle of a complicated rebase, I'm on rebase 6/10.
Somehow, it appears that a class required by both branches got deleted along the way. I'm not sure how that happened. So according to git 'they' deleted the file, to resolve this and restore the file, is it just a case of adding the two modified files and ignoring the deleted one, then doing git rebase --continue ? Will that restore the ControllerBase.java file?

git rebase screenshot


Solution

  • Yes, you can.

    git checkout --ours -- fullpath/to/ControllerBase.java
    git add fullpath/to/ControllerBase.java
    git rebase --continue
    

    should be enough since it's on the "theirs" part that deletion happened.