Reputation: 19768
I'm trying to merge from a source branch that has deleted some of the files that've been modified in the target branch. I want to ignore the deletions and simply accept what the destination branch already has.
When I:
git merge -s recursive -X ours master
the output of git status
is:
# On branch nyap-artifactory
# Changes to be committed:
#
# new file: file-re-added-by-source-branch-that-should-be-deleted
# modified: file-modified-by-source-branch
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# deleted by them: file-deleted-by-source-branch-that-should-be-kept
What's the next step?
Upvotes: 3
Views: 1583
Reputation: 392931
You should just re-add the file to the index:
git checkout HEAD -- file-deleted-by-source-branch-that-should-be-kept
and commit the merge.
What this does is get the latest version from the nyap-artifactory
branch. [*]
[*] (A git reset -- file-deleted-by-source-branch-that-should-be-kept
might be enough, but is a bit trickier to work with, since it doesn't necessarily update the working tree, and has options that are powerful enough to accidentally lose data).
Upvotes: 2
Reputation: 696
git add file-name and the commit the merge. Similar question here with further explanation: git - merge conflict when local is deleted but file exists in remote
Upvotes: 1