Home > Software design >  How do I fix a merge conflict due to removal of a file in a using cherry-pick?
How do I fix a merge conflict due to removal of a file in a using cherry-pick?

Time:09-14

 git cherry-pick --strategy=recursive -X theirs -n "$GitHub_SHA" 

Hello, I'm specifying -s recursive -X theirs, why is it still necessary to git rm and git add?

Also how do i differentiate when to git rm or git add in my bash script?

git cherry-pick --strategy=recursive -X theirs -n "$GitHub_SHA" || merge_conflict=1

   if [ ${merge_conflict:-0} -eq 1 ]
    then
    git add -all
   fi

CodePudding user response:

-X theirs and -X ours act on conflicting hunks. If a file has been removed by one side, no conflicting hunks are generated. At the same time, the context lines are not generated either. Without the hunks and context lines, the strategy option cannot pick lines.

To differentiate one conflicting type from another, you could try git status -s and parse the result in short format. For details on short format, see Short Format. For example, for a deleted by us file foo.txt, git status -s foo.txt prints DU foo.txt. For both modified, it's UU foo.txt.

  • Related