推送分支和标签时,出现错误:无法生成git:没有此类文件或目录 [英] When pushing branches and tags, get error: cannot spawn git: no such file or directory

查看:168
本文介绍了推送分支和标签时,出现错误:无法生成git:没有此类文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的,裸露的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吗?如果您有大量标签,就会发生这种情况.参见这篇文章.

I have an existing, bare, Git repository created from importing our source and history from CVS. I make a mirror, using:

git clone --mirror git://aserver.adomain.com/myrepo

Then, I want to push all branches and tags to our internal Git repo host, but the push doesn't seem to see the bare repository as a Git repo.

I have tried the following:

git clone --mirror git://aserver.adomain.com/myrepo
git remote set-url origin http://user@anotherserver.adomain.com/project/myrepo.git
git push origin

which results in:

$ git push origin
Password for 'xxxx':
error: cannot spawn git: No such file or directory

or I try:

$ 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

What is the meaning of "cannot spawn git"?

How can I push a bare repo, with all branches, to an empty existing one?

I have googled several possibilities and reviewed several SO issues, but I don't see a solution to this problem. Clearly, my understanding of this process is flawed.

Update

I guess my understanding was not flawed. The error somehow misled me to think that there was something wrong with the bare repository, as I could clone and push branch by branch just fine from "regular" clones.

As it turns out, this is a bug in MSysGit. I moved to Linux because retaining all of the history was a requirement, in my case. I couldn't simply remove branches and tags, as these needed to be pushed to the empty remote repo. So, the following did work:

$ 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

解决方案

As this comment led to a solution (see edit at end of question), here it is reposted as an answer:

Are you using MSysGit? This has been known to happen if you have a large number of tags. See This post.

这篇关于推送分支和标签时,出现错误:无法生成git:没有此类文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆