问题
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