我有一个现有的裸 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 吗?如果您有大量标签,就会发生这种情况。参见 This post .
关于git - 推送分支和标签时,出现错误 : cannot spawn git: no such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14867232/