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"?
'deleted by us' means the file is deleted in the commit which you are trying to do a cherry-pick. It is not file is deleted by you. Git tells that the file was deleted in some other commit, and allows you to decide to retain it (git add) or to remove it. You can do git cherry-pick --continue once you sort this out.
If you have a merge conflict on the command line, you cannot push your local changes to GitHub until you resolve the merge conflict locally on your computer. If you try merging branches on the command line that have a merge conflict, you'll get an error message.
What is a Git Merge Conflict? A merge conflict is an event that takes place when Git is unable to automatically resolve differences in code between two commits. Git can merge the changes automatically only if the commits are on different lines or branches.
Luckily, Git offers powerful tools to help navigate and resolve conflicts. Git can handle most merges on its own with automatic merging features. A conflict arises when two separate branches have made edits to the same line in a file, or when a file has been deleted in one branch but edited in the other.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With