曾经沧海难为水,除却巫山不是云。|

Joey-Wang

园龄:4年2个月粉丝:17关注:0

📂Git
🔖Git
2022-11-14 17:24阅读: 1949评论: 0推荐: 1

fork公共仓库并改为私有

方法二为bustub官方推荐。目前不清楚这两种方法是否有区别,但实际尝试中两种方法中,第一种方法会跳出不明的 pull request,第二种不会。

方法一

  1. 在 “create a new repository” 页面选择“import a repository”。
image-20221114165800594
  1. 填上要clone仓库的url和想创建的私有仓库的名称,然后选择“Private”,最后点击“Begin Import”。
image-20221114165617496
  1. 将该private仓库clone到本地开发后,添加原public仓库作为第二个remote,这便于及时获取公共库后续的更改。
# 查看所有的远程库
$ git remote -v   
# 添加远程库,取名为public
$ git remote add public https://github.com/cmu-db/bustub.git 

方法二

  1. 在“create a new repository” 页面中直接创建一个private仓库,如 bustub-private。

  2. 在本地创建一个原仓库的 bare clone,取名 bustub-public:

$ git clone --bare https://github.com/cmu-db/bustub.git bustub-public
  1. 将原public仓库 mirror 到我们自己的private方库,这样就将public仓库的所有东西都推到private仓库中:
$ cd bustub-public

# If you pull / push over HTTPS
$ git push https://github.com/student/bustub-private.git master
# If you pull / push over SSH
$ git push git@github.com:student/bustub-private.git master
  1. 删除本地对public仓库的clone:
$ cd ..
$ rm -rf bustub-public
  1. 将自己private仓库clone到本地机器:
# If you pull / push over HTTPS
$ git clone https://github.com/student/bustub-private.git
# If you pull / push over SSH
$ git clone git@github.com:student/bustub-private.git
  1. 添加public库作为第二个remote,这便于及时获取公共库后续的更改。
$ git remote add public https://github.com/cmu-db/bustub.git
  1. 我们可以查看现有的远程库信息,来确认已经添加好了remote
$ git remote -v
origin	https://github.com/student/bustub-private.git (fetch)
origin	https://github.com/student/bustub-private.git (push)
public	https://github.com/cmu-db/bustub.git (fetch)
public	https://github.com/cmu-db/bustub.git (push)

本文作者:Joey-Wang

本文链接:https://www.cnblogs.com/joey-wang/p/16889680.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Joey-Wang  阅读(1949)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开