Git:合并到主文件,同时自动选择用分支覆盖主文件 [英] Git: Merge to master while automatically choosing to overwrite master files with branch

查看:27
本文介绍了Git:合并到主文件,同时自动选择用分支覆盖主文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Git 来跟踪我的文档乳胶源.我想让 master 分支充满适合最终用户发布的文档,所以当有人需要什么时,我可以切换到 master 分支,编译并分发文档.

I am using Git to track my documentation latex source. I want to keep the master branch full of documents that are suitable for end user release, so when someone needs something, i can just switch to the master branch, compile and hand out the document.

当手册需要重大更新时,我会创建新分支.但是,当手册获得批准后,它需要合并回母版.当从 branch 合并到 master 时,我想通过一些命令给 Git 说,忘记合并,只使用 branch 中的文件em> 覆盖 master 中的文件."有没有办法做到这一点?具体来说,我想避免每次都打开合并工具.提前致谢.

I make new branches when a manual needs a major update. But, when the manual is approved, it needs to get merged back into the master. When merging from branch into master, I would like to pass some command to Git to say, "forget the merging, just use the the file from branch to overwrite the file in master." Is there a way to do this? Specifically, I want to avoid opening up a merge tool every time. Thanks in advance.

推荐答案

忽略master,当你检出branch后:

git merge master --strategy=ours

http://schacon.github.com/git/git-merge.html

正如计算机语言学家"在此处评论的那样,这将忽略来自 'master' 的所有内容,即使它对新的独立文件进行了更改".因此,如果您不是 OP 并且想要更安全的合并,而不是 OP 所说的忘记合并",那么请使用来自计算机语言学家"的这个出色的安全命令,并加上他的评论,以便他获得信任.

As 'Computer Linguist' commented here, this will "ignore everything from 'master', even if it has changes to new, independent files". So if you are not the OP and want a more safe merge that does not as the OP says "forget the merging", then use this excellent safe command from 'Computer Linguist', and plus his comment up so he gets creds.

git merge -s recursive -X theirs branch

这篇关于Git:合并到主文件,同时自动选择用分支覆盖主文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆