あなたのプロセスはほぼ完璧です。--mirror
唯一のことは、最初のクローンでパラメーターが欠落していたことです。
# create the private repo
ssh private-server
mkdir -p /path/to/shared/repos
git init --shared={whatever makes sense for your environment} /path/to/shared/repos/internalrepo.git
exit
# go to github.com and make the public repo readonly
# create a local mirror
git clone --bare --mirror $Github-URL github.git
# now the local repo github.git contains all the stuff from the github repo
cd github.git
git push --mirror $Private-URL
# Tell all developers to execute `git remote set-url origin $Private-URL`
# Done
どのリポジトリが現在正しいリポジトリであるかがプロジェクトの全員に明確ではないため、変更のために github リポジトリを開いたままにしません。サーバーレポで実行すれば、まだ実行できます
ssh private-server
cd /path/to/shared/repos/internalrepo.git
git remote add --mirror github $Github-URL
そして定期的に (cron ジョブのように)
git fetch github # get new commits from github
git remote prune github # drop branches, which are now deleted in the github repo
編集
ローカル ミラーを使用して交換を行うこともできます。しかし、git は削除されたブランチをどうするか、分岐したブランチをどうするかを決めることができないため、簡単な自動化プロセスはありません。したがって、以前の github-repo から定期的に取得し、内部リポジトリから取得し、分岐履歴を解決し、この内容を内部リポジトリにプッシュする作業リポジトリを保持する必要があります。