66

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"?

taras
  • 1,239
  • 1
  • 10
  • 16
  • 2
    If you already commit this file in at least one commit, then it will stay here "forever" (unless you loose all references to this commit and invoke Git garbage collection). – user4003407 Feb 11 '17 at 09:58
  • Possible duplicate of [git - merge conflict when local is deleted but file exists in remote](https://stackoverflow.com/questions/4319486/git-merge-conflict-when-local-is-deleted-but-file-exists-in-remote) – IMSoP Jul 19 '19 at 09:30

1 Answers1

104

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.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • 46
    "deleted by us" means it was deleted by "them"? – xaxxon Mar 29 '19 at 18:36
  • 8
    @xaxxon See this [canonical answer](https://stackoverflow.com/questions/21025314/who-is-us-and-who-is-them-according-to-git) 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. – Tim Biegeleisen Mar 30 '19 at 00:26