前陣子在改非常舊的沒有 LICENSE
的故障 public repo 時,想說要先改成 private repo 後,要發佈時再調整為 public repo,才發現在 Github 沒辦法直接一鍵調整成 private repo。
這時候需要改成使用 Duplicating a repo 的步驟進行,例如:
我要 duplicate 一個 public repo camel2243/camel-blog-comments 成 private repo
- 建立一個 Bare clone repo (僅有
git
歷史紀錄)
git clone --bare [email protected]:camel2243/camel-blog-comments.git
-
在 Github 上建立一個新的 private repo
<your_username>/new-repo
-
將 Bare clone repo 推到新的 repo
cd camel-blog-comments.git
git push --mirror [email protected]:<your_username>/new-repo.git
- 刪除 Bare clone repo
cd ..
rm -rf camel-blog-comments.git
- Clone 你的新 repo
git clone [email protected]:<your_username>/new-repo.git
- 這時你可以在
設定
中看到你的 repo 是 private repo,並且可以進行相關設定 🎉