单个Git存储库中的公共和私有代码 [英] Public and private code in a single Git repository

查看:64
本文介绍了单个Git存储库中的公共和私有代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在参加的一个研究小组目前将所有代码托管在一个私人SVN存储库中.我们想打开我们的代码并将其大部分移到Github上.问题是,某些代码是敏感的,不应打开,但我们仍希望它在版本控制下.目前,我们在Github上有开放代码,而私有代码仍在私有SVN存储库中.有没有在单个Git存储库中执行此操作的好方法?

解决方案

只有一个git存储库,否.您可以使用 git子模块,它可以使您组合"存储库.将您的公共代码保存在github上,为您的私有代码创建另一个私有托管的git存储库,该存储库将公共代码作为子模块进行引用.在公共子模块中进行的更改可以上推至github,而在github上的更改可以撤回至下级,但子模块外部的更改不会向公共社区公开.尽管代码树将被合并到一个根目录中,但是您将不得不在单独的模块之间独立地管理提交,推送和拉取,这在很多人看来都是繁琐且有问题的,因此在广泛分发之前,您应该对工作流进行一些试验. /p>

A research group I'm participating in currently hosts all of their code in a private SVN repository. We'd like to open up our code and move most of it onto Github. The problem is, some of the code is sensitive and should not be opened up, but we still want it under version control. At the moment, we have the open code on Github and the private code still in the private SVN repository. Is there a good way to do this in a single Git repository?

解决方案

With a single git repository, no. What you can do is use git submodules, which allow you to "combine" repositories. Keep your public code on github, create another, privately hosted, git repository for your private code which references the public code as a submodule. Changes made within the public submodule can be pushed up to github, and changes on github can be pulled back down, but changes outside the submodule won't be exposed to the public community. Although the code trees will be merged into a single root you will have to manage commits, pushes, and pulls independently between the separate modules, which many people find cumbersome and problematic, so you should do some experimentation with the workflow before distributing widely.

这篇关于单个Git存储库中的公共和私有代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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