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

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

问题描述

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

因此,我们有以下几点:

 (Production Init提交)(正式发布)
/ /
o ------------------------- o [master]
\ /
o ------ o --------- o ---- o [pre-release]
\ /
o --- --O [功能]
\ < - 是否允许/可能/不良想法?
\
o ------------ O [DEV](孤立分支)
/
(我们的沙箱环境中的初始提交)


解决方案

合并不具有公共根提交的提交Git的。结果将包含两个分支中存在的文件的联合。这是将两个项目合并到单个存储库的常见做法(例如,Git项目本身始于 e83c51633 ,gitk开始于 1db95b00 ,并且两个项目都在稍后合并在5569bf9bb)。



现在,无论你真的想要这样做,真的取决于分支的内容。如果您将沙盒分支合并到您的功能分支中,则将您的功能分支合并到主分支中也会将您的沙盒代码放入主分支,这可能不需要。


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)

解决方案

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合并提交到一个孤儿分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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