GitHub 仓库直接 fork 的话就是 public,但有时候想要设置为 private,有没有办法呢?办法当然是有的。
进入 GitHub,新建一个 private 仓库,例如:
https://github.com/varm/awesome-me
克隆需要 fork 的“裸库”:
git clone --bare https://github.com/other/public-repo.git
以镜像推送的方式上传代码到私有仓库
cd public-repo.git git push --mirror https://github.com/varm/awesome-me.git
删除本地代码
cd .. rm -rf public-repo.git
Clone 新仓库到本地
git clone https://github.com/varm/awesome-me.git
这样可以保留原版本库中的所有内容,可以适用于代码迁移。