Git Merge 提交到孤儿分支 [英] Git Merge commits into an orphan branch

查看:34
本文介绍了Git Merge 提交到孤儿分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道您是否可以,以及将提交合并到我的孤儿分支是否有任何问题.对于这个特定实例,我的 Salesforce 存储库有一个主分支和一个预发布分支,但因为我们的沙箱环境通常具有不属于生产的元数据,但我们希望对其进行版本控制,但与我们干净的预发布分支足够分离.

I'm curious to know if you CAN and if there is anything wrong with merging commits INTO my orphan branch. For this specific instance my Salesforce repository has a master branch and a pre-release branch but because our sandbox environment often has metadata that is not part of production yet we want to version control it but separate enough from our clean pre-release branch.

因此,我们有以下内容:

So as it is we have the following:

(Production Init Commit)    (official release)
 /                         /
o-------------------------o [master]
                        /
  o------o---------o----o [pre-release]
                 /
           o-----O [feature]
                   <-- IS THIS ALLOWED/POSSIBLE/BAD IDEA?
                    
       o------------O [DEV] (orphan branch)
      /
     (Initial commit from our sandbox environment)

推荐答案

Git 允许合并没有公共根提交的提交.结果将包含两个分支中存在的文件的并集.这是将两个项目合并到一个存储库中的常见做法(例如,Git 项目本身开始于 e83c51633,gitk开始于1db95b00,后来两个项目合并在 5569bf9bb).

Merging commits that do not have a common root commit is allowed with Git. The result will contain the union of the files present in both branches. This is a common practice to merge two projects into a single repository (for example, the Git project itself was started at e83c51633, gitk was started at 1db95b00, and both projects were merged later at 5569bf9bb).

现在,您是否真的想要这样做实际上取决于分支的内容.如果您将沙箱分支合并到功能分支中,那么将功能分支合并到主分支也会将沙箱代码带入主分支,这可能是您不想要的.

Now, whether you actually want to do that really depends on the content of branches. If you merge your sandbox branch into your feature branch, then merging your feature branch into master will also bring your sandbox code into master, which you probably don't want.

这篇关于Git Merge 提交到孤儿分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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