Overriding alternative to cherry-pick

a 夏天 提交于 2019-12-10 10:58:15

问题


There is a cherry-pick command in the git which allows me to copy some commit on top of the current. However, it does some conflict resolution, that I do not care about. What is alternative to cherry-pick which just copies picked commit over on top of current commit?

I can do it manually: select desired commit, copy its files, save them into non-managed folder, select current commit which will be the base for new one, copy the archived files into the git working folder. Separately, I have to copy the commit message. This is huge hassle that I do currently to avoid the change conflicts. Which command can help me to achieve the goal automatically?


回答1:


You could use the merge strategy option 'theirs':

git cherry-pick <SHA-1> -Xtheirs

Where <SHA-1> is the hash of the commit you want to cherry pick into your branch.

This means that, in case of conflict, Git would always resolve it with the version of commit being cherry-picked ("theirs").


Note that, even without that option, you can do the same manually (but that would not scale well with many files)

git cherry-pick <SHA-1>
error: could not apply <SHA-1>... [Commit Message]
hint: after resolving the conflicts, mark the corrected paths

git checkout --theirs path/to/conflicted_file.php
git add path/to/conflicted_file.php


来源:https://stackoverflow.com/questions/34173704/overriding-alternative-to-cherry-pick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!