【发布时间】:2013-02-14 03:18:00
【问题描述】:
我有一个现有的、裸露的 Git 存储库,它是通过从 CVS 导入我们的源代码和历史记录而创建的。我做了一面镜子,使用:
git clone --mirror git://aserver.adomain.com/myrepo
然后,我想将所有分支和标签推送到我们内部的 Git 存储库主机,但推送似乎没有将裸存储库视为 Git 存储库。
我尝试了以下方法:
git clone --mirror git://aserver.adomain.com/myrepo
git remote set-url origin http://user@anotherserver.adomain.com/project/myrepo.git
git push origin
导致:
$ git push origin
Password for 'xxxx':
error: cannot spawn git: No such file or directory
或者我试试:
$ git remote rm origin
Note: Some branches outside the refs/remotes/ hierarchy were not removed;
to delete them, use:
...a whole lot of branches...
user@SOMEMACHINE /some/path/myrepo.git (BARE:master)
$ ls
HEAD config description hooks info objects packed-refs refs
user@SOMEMACHINE /some/path/myrepo.git (BARE:master)
$ git branch -a
...a whole lot of local branches...
user@SOMEMACHINE /some/path/myrepo.git (BARE:master)
$ git remote add mygithost http://user@anotherserver.adomain.com/project/myrepo.git
user@SOMEMACHINE /some/path/myrepo.git (BARE:master)
$ git push --all mygithost
Password for 'xxxx':
error: cannot spawn git: No such file or directory
“无法生成 git”是什么意思?
如何将包含所有分支的裸仓库推送到现有的空仓库?
我搜索了几种可能性并查看了几个 SO 问题,但我没有看到解决此问题的方法。显然,我对这个过程的理解是有缺陷的。
更新
我想我的理解没有缺陷。该错误以某种方式误导我认为裸存储库有问题,因为我可以从“常规”克隆中克隆并逐个分支推送。
事实证明,这是 MSysGit 中的一个错误。我搬到 Linux 是因为保留所有历史记录是我的要求。我不能简单地删除分支和标签,因为它们需要被推送到空的远程仓库。因此,以下确实有效:
$ git remote rm origin
$ git clone --mirror git://aserver.adomain.com/myrepo
$ cd /some/path/myrepo.git
$ git remote add mygithost http://user@anotherserver.adomain.com/project/myrepo.git
$ git push --all mygithost
$ git push --tags mygithost
【问题讨论】:
-
你在使用 MSysGit 吗?众所周知,如果您有大量标签,就会发生这种情况。见groups.google.com/forum/#!msg/msysgit/6bFAPUQDQLI/USrCnnZ4x5QJ
-
是的,我是。这可能会有所帮助。我会在 Linux 上试试这个。
-
就是这样。在linux上工作得很好。请将此作为答案发布,以便我接受。