简体   繁体   English

一次将git与多个分支一起使用

[英]Using git with multiple branches at once

Does git support a view where different files come from different branches? git是否支持视图,其中不同文件来自不同分支?

Here is my setup -- I have a simple git branch structure with master being used for all development and installs at the client site. 这是我的设置-我有一个简单的git分支结构,其中master用于所有开发并在客户端站点上安装。 Since the client setup is different from my setup, I have a small number of a files on a different branch, called "my_company_name". 由于客户端设置与我的设置不同,因此我在另一个分支上有少量文件,称为“ my_company_name”。 Files that specify hostnames, for example, would be in this category. 例如,指定主机名的文件将在此类别中。

What I'd like to do is work on the master branch, but get specific files from my_company_name. 我想在master分支上工作,但是要从my_company_name获取特定文件。 I understand that I could accomplish the same thing by: 我了解我可以通过以下方式完成相同的操作:

  1. git checkout my_company_name git checkout my_company_name
  2. git merge origin master git merge origin master

but I would need to specify 'origin master' each time I push, or the files will be going to my_company_name. 但我每次按下时都需要指定“原始主机”,否则文件将进入my_company_name。 If I do the opposite: 如果我做相反的事情:

  1. git checkout master git checkout主
  2. git merge origin my_company_name git merge origin my_company_name

then I would need to make changes in the site-specific files before installing at the client site. 那么在客户端站点上安装之前,我需要在特定于站点的文件中进行更改。

How does git support this? git如何支持这一点?

您可以使用repo来管理带有几个git存储库的工作空间。

You should look at smudge/clean scripts instead of branches for this. 您应该为此查看污迹/清除脚本而不是分支。 See the git attributes chapter in the progit.org/book. 请参阅progit.org/book中的git属性章节。 Or just use plain scripts. 或者只使用普通脚本。

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

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