Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“转让”;权威的;从Github到私有Github的git存储库_Git_Github - Fatal编程技术网

“转让”;权威的;从Github到私有Github的git存储库

“转让”;权威的;从Github到私有Github的git存储库,git,github,Git,Github,我的任务是将存储库从公共github移动到本地网络上github的私有实例 我的想法是用你的手移动它们 git clone --bare <github-repo-url> git push --mirror <local-github-url> git克隆--bare git推——镜像 在过渡期间,我应该能够从github上的存储库中自动更新镜像。(或者我会吗?我在UI中找不到执行更新的命令。) 然后我将删除“权威”github存储库,镜像将成为权威 但这是怎么发生

我的任务是将存储库从公共github移动到本地网络上github的私有实例

我的想法是用你的手移动它们

git clone --bare <github-repo-url>
git push --mirror <local-github-url>
git克隆--bare
git推——镜像
在过渡期间,我应该能够从github上的存储库中自动更新镜像。(或者我会吗?我在UI中找不到执行更新的命令。)

然后我将删除“权威”github存储库,镜像将成为权威

但这是怎么发生的呢?每个开发人员是否需要更改.git/config中“origin”的url


镜像会接受不是来自其克隆父级的更新的推送吗?

最简单的过程是开发人员克隆新的(私有)回购并从那里继续。

如果他们在以前的回购协议中有任何未决变更,他们可以将这些变更导出为补丁,并将其应用于新的本地克隆回购协议,然后再将其推回到新的
来源
。(请参见和)

您的流程几乎完美无瑕。唯一的问题是初始克隆上缺少一个
--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回购协议对变更开放,因为项目中的每个人都不清楚哪种回购协议是正确的回购协议。如果在服务器repo上运行,您仍然可以这样做

ssh private-server
cd /path/to/shared/repos/internalrepo.git
git remote add --mirror github $Github-URL
然后定期(比如在cron工作中)

编辑


您还可以使用本地镜像进行交换。但是没有简单的自动化过程,因为git既不能决定如何处理删除的分支,也不能决定如何处理发散的分支。Sou您需要保持一个工作存储库,在那里您可以定期从以前的github回购中获取内容,从内部回购中获取内容,解决分歧历史,并将这些内容推回到内部回购中。

Rudi,回答得很好!然而,它假设私有回购在我有shell/crontab的机器上。在我的例子中,私有回购位于防火墙内的“Github Enterprise”实例上。除了通过git和网站,我没有直接访问私有存储库的权限。我还没有看到GHE的解决方案。甚至GHE网站上的一些讨论也被删除了。更多信息:“本地github url”确实是一个github。这是一个私有的Github企业服务。我没有shell或crontab访问私有Github的权限。
git fetch github # get new commits from github
git remote prune github # drop branches, which are now deleted in the github repo