78

A few days ago I made a new branch called "new_branch" based on "master". While I worked on my "new_branch" with file "file.php", a second developer on his branch deleted the file "file.php" and merged his branch with "master". Now I need to rebase my branch on current "master". After the command git pull --rebase origin master I have the conflict

deleted by us: app/file.php

I don't know what to do, I don't want to lose changes I've made in this file. After commands

git add -A
git rebase --continue 

will the file disappear in my "new_branch"?

2

1 Answer 1

118

The message deleted by us: app/file.php means precisely what you described, namely that someone deleted this file in the master branch on which you are rebasing new_branch.

Assuming that the delete has not yet been staged and you want to keep this file, then you should git add the file to mark it that it should be kept:

git add app/file.php

Then, resolve all other merge conflicts and do git rebase --continue

Note that if you wanted to accept the delete you would do git rm instead.

2
  • 57
    "deleted by us" means it was deleted by "them"?
    – xaxxon
    Commented Mar 29, 2019 at 18:36
  • 11
    @xaxxon See this canonical answer for an explanation. In a rebase, "us" becomes the branch against which you are applying the commits, which is when the merge conflict due to the deleted file occurs. Commented Mar 30, 2019 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.