如何将开源项目部分代码作为private放在github上?

  很多时候,你的一些项目本身都是开源的,但是基于该开源项目,你可能做了部分更有价值的工作,或者由于其他原因,你不希望将这部分代码放到public上,那么有以下简单方法:

1. 创建一个private branch;

2. 创建一个private repo(github需要付费);

3. 增加你的另外一个remote,将private local branch 指向private remote的private remote branch;

4. push那个private remote,这样你的private branch的代码就放到了private repo中

实际上这个工作流程很像本地的feature branch,这个feature branch本身是不会push到central repo的,直到直接feature完成,最后merge到master上才会做push分享。但是本文所介绍的工作流实际上是将feature branch push到一个private remote上去,在该private remote上仍然可以支持team work,工作完毕后,你需要做的是在master branch上merge那个feature branch的内容(实际上是一个remote tracking branch),随后再push到public上,就算是向公众发布了(这时private repo就可以删除了)。

注意:所谓Push到一个remote repo中,这时remote repo就包含了所有的历史,但是却只有一个branch作为Local repo的remote branch

原文地址:https://www.cnblogs.com/kidsitcn/p/4542461.html