从Github转移“权威”git存储库到私人github
问题描述:
我的任务是将我们的存储库从公共github移动到我们本地网络上的github私有实例。从Github转移“权威”git存储库到私人github
我的想法是将它们与
git clone --bare <github-repo-url>
git push --mirror <local-github-url>
在移动过程中的过渡时间,我应该能够做镜像更新自己从爸爸GitHub上的仓库。 (或者我会吗?我还没有在UI中发现一条命令来进行更新。)
然后我将删除“权威”的github存储库,镜像将变得权威。
但这是如何发生的?每个开发者是否需要在.git/config中更改“origin”的url?
镜像是否接受不是来自其克隆父亲的更新?
答
最简单的过程是让开发人员克隆新(私人)回购并从那里继续。
如果他们在以前的回购中有任何待处理的更改正在进行,他们可以将这些更改导出为补丁并将它们应用于新的本地克隆回购,然后再推回到新的origin
。 (见What is the difference between 'git format-patch
' and 'git diff
'?和git format-patch
man)
答
你的过程几乎完美。唯一的原因是初始克隆中缺少--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获取东西,从内部仓库获取东西,解决分歧历史,并将这些东西推回到内部仓库。
更多信息:“local-github-url”确实是一个Github。这是一个私人Github企业服务。我没有shell或crontab访问私人Github。 – Mojo 2012-04-27 21:09:22