Git merge strategy to ignore deleted files

后端 未结 4 1260
悲&欢浪女
悲&欢浪女 2020-12-30 00:45

I have special branch (release branch) which is an exact copy of master branch with some files and directories removed. No development is happening on this branch, however i

相关标签:
4条回答
  • 2020-12-30 01:24

    There's probably a better way to do this, but I solved a similar problem by doing the merge (with the default merge strategy) and then running

    git status | grep 'deleted by us' | awk '{print $4}' | xargs git rm
    

    After this, you should resolve other conflicts as normal and then commit.

    This just deletes all files that had been deleted on the current branch, which I think is what you want.

    0 讨论(0)
  • 2020-12-30 01:31
    git merge master
    git status --porcelain | awk '{if ($1=="DU") print $2}' | xargs git rm
    git commit
    
    0 讨论(0)
  • 2020-12-30 01:40

    By having a look at this question, it looks like the recursive strategy with ours or their option doesn't consider a deletion as a conflict.

    What you can do though is use this feature to specify a specific strategy for some files. I would bet that the ours strategy (not option) would do the trick for those files.

    EDIT:

    As stated in the comment, you can't do this !

    You should definitly contact Git mailing list if this is a very important feature to you (git@vger.kernel.org)

    0 讨论(0)
  • 2020-12-30 01:40

    You can use rebase instead of merge to actualize release branch.

    0 讨论(0)
提交回复
热议问题