git merge: 保留一些文件的一侧,手动合并其余部分
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1597508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:54:31 来源:igfitidea点击:
git merge: keep one side for some files, manual merge the rest
提问by Ivan
In a merge with conflicts, is there a way to tell git to keep one version for a set of files?
在合并冲突时,有没有办法告诉 git 为一组文件保留一个版本?
$ git checkout some_branch
$ git merge origin/master
$ ?
回答by Cascabel
If you've already attempted the merge and are looking at the unmerged files, you can use git checkout:
如果您已经尝试过合并并且正在查看未合并的文件,则可以使用 git checkout:
git checkout some_branch
git merge origin/master
<conflicts!>
git checkout --theirs -- <dir>|<file>
(and of course, --ours
keeps the version from the current branch)
(当然,--ours
保留当前分支的版本)