I run the following command:
git cherry-pick SHA --strategy-option theirs
and get a conflict like this waiting for manual resolution:
deleted by us: SOME_FILE
Is there a way to make git automatically resolve such conflicts by adding files deleted by us?
'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.
When you pull or merge branches, Git will select the recursive strategy as default. The recursive strategy only can detect and do merges which involve renames, but cannot use detected copies. The ours option forces conflicted parts to be automatically resolved by favoring 'our' version.
Select Stage Changed Files To Commit (Ctrl-I) from Commit menu. Enter a commit comment like "deleted conflicting file" Commit (ctrl-enter) Now if you restart the merge it will (hopefully) work.
deleted by us are the new files which you added in your commit (getting cherry picked). But these files are not present in the current branch (the one in which you are cherry-picking into).
So in this case you have to add these files manually by running:
git add <file-path>
However if you think, these files will no longer be needed in the current branch after cherry picking, in that case you can do:
git rm <file-path>
If you are sure you want to add all "deleted by us" files, you could do:
git status | sed -n 's/deleted by us://p' | xargs git add
or, if you want to remove all "deleted by us" files:
git status | sed -n 's/deleted by us://p' | xargs git rm
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