繁体   English   中英

我怎样才能使git保留另一个分支文件

[英]How can i make git keep another branch files

我有两个分支B

我想将B与A合并

应该添加新文件。

但是如果两个文件都被更改,那么我想保留B的文件。 但是git正在自动合并它们

我正在用这个

git checkout A
git merge -xtheirs B  

我认为您最好的选择是临时创建一个.gitattributes文件,该文件将所有内容声明为二进制,或者所有内容都应使用“二进制”合并驱动程序。 然后执行git merge,然后git添加所有冲突的文件以将其标记为已解决,然后git commit。 [[不要忘了以后重置/删除temp .gitattributes文件。]]

https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

Built-in merge drivers
...
binary
Keep the version from your branch in the work tree, but
leave the path in the conflicted state for the user to sort out.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM