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)
posted @ 2022-11-14 17:24  Joey-Wang  阅读(2389)  评论(0)    收藏  举报