Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT: How dangerous is "deleted by us" conflict?

Tags:

git

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

like image 348
taras Avatar asked Feb 11 '17 09:02

taras


People also ask

How do you resolve deleted by US conflict?

'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.

What happens if theres a conflict in GitHub commit?

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.

Does Git automatically resolve conflicts?

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.

How does Git deal with conflicts?

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.


1 Answers

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.

like image 136
Tim Biegeleisen Avatar answered Oct 06 '22 14:10

Tim Biegeleisen