Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When pushing branches and tags, get error: cannot spawn git: no such file or directory

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://[email protected]/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://[email protected]/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://[email protected]/project/myrepo.git
$ git push --all mygithost
$ git push --tags mygithost
like image 303
kevinmm Avatar asked Feb 14 '13 03:02

kevinmm


1 Answers

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.

like image 165
Neil Forrester Avatar answered Oct 03 '22 04:10

Neil Forrester