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

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

问题描述

我使用Git来跟踪我的文档胶乳源代码。我想让主分支充满适合最终用户发布的文档,所以当有人需要某些东西时,我可以切换到主分支,编译并分发文档。

当手册需要重大更新时,我会新建分支。但是,当手册获得批准后,需要将其合并回主文件中。当从分支合并到 master 中时,我想传递一些命令给Git说:忘记合并,只使用分支 em>覆盖 master 中的文件。有没有办法做到这一点?具体来说,我想避免每次都打开合并工具。 如果您有 branch 然后检出:

  git merge master --strategy = ours 

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



由于'计算机语言学家'在这里评论,这将忽略来自'主'的所有内容,即使它改变了新的独立文件。因此,如果你不是OP,并希望有一个更安全的合并,而不是像OP所说的那样忘记合并,那么使用'Computer Linguist'这个优秀的安全命令,再加上他的评论,这样他就可以获得信任。 p>

  git merge -s递归-X他们的分支


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.

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.

解决方案

To disregard master, when you have branch checked out then:

git merge master --strategy=ours

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

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天全站免登陆