2

I am a new git user.

I have a repository on bitbucket that I would like to import into a .git folder I have created on my live shared host web server ( where I have git installed ). I can give commands via SSH. I am following the instructions in http://joemaller.com/990/a-web-focused-git-workflow/

I have been able to set up the 2 repos on the server as described in the article. However when give the command:

"git remote add hub ~/site_hub.git; git remote show hub; git push hub master; "

I get:

Push URL: /home/***/site_hub.git HEAD branch: (unknown) 
error: src refspec master does not match any. 
error: failed to push some refs to '/home/***/site_hub.git' 

How can I fix this?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
user1592380
  • 34,265
  • 92
  • 284
  • 515

1 Answers1

1

You cannot push to an empty repository: it doesn't contain yet a master branch.

For bare repo, try a:

git push -u origin master

This is because of a recent push policy change.

In your case, your remote bare repo is called hub, so:

git push -u hub master

The OP still get an error:

src refspec master does not match any. 
error: failed to push some refs to '/home/*****/site_hub.git 

But that is the case only if no commits were ever done on master of the source repo.
And indeed, the OP reports:

I had a syntax error error, preventing the add command from working in the 'prime' repository.
After fixing this the files appeared to add correctly. I then ran 'git push hub master' and there now appear to be files in the site_hub.git/objects/pack directory which I assume are the pushed files.


For non-bare repo, make an empty commit first in the destination local repo.

See, for concrete examples:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Now I tried: cd site_hub.git; touch README; git add README; git commit -m 'first commit'; but I get: fatal: This operation must be run in a work tree fatal: This operation must be run in a work tree .what have I done wrong? – user1592380 Nov 17 '12 at 07:33
  • @user61629 right, this is a bare repo, so no commit possible directly in it. I have updated my answer. If it is not working, try changing the push policy. – VonC Nov 17 '12 at 07:39
  • I tried, git push -u origin master I am now getting: fatal: 'origin' does not appear to be a git repository fatal: The remote end hung up unexpectedly. I am wondering if it should be git push -u hub master in this case based on the article? – user1592380 Nov 17 '12 at 15:38
  • I tried to checkout the master branch while in the prime directory. This gives: pathspec 'master' did not match any file(s) known to git.so it seems that master branch is not defined? – user1592380 Nov 17 '12 at 15:53
  • from the prime directory as in the article. git remote -v show gives: hub /home/*****/site_hub.git (fetch) hub /home/*****/site_hub.git (push) – user1592380 Nov 17 '12 at 19:46
  • @user61629 right, I didn't see at first your remote repo was called `hub`. So what does `git push -u hub master` does? – VonC Nov 17 '12 at 20:00
  • output: src refspec master does not match any. error: failed to push some refs to '/home/*****/site_hub.git – user1592380 Nov 18 '12 at 19:45
  • @user61629 that message would only possible if you don't have any commit or master branch on your *source* Git repo (the one your are pushing from). – VonC Nov 18 '12 at 19:55
  • VonC, I am oficially an idiot. I had a syntax error error, preventing the add command from working in the 'prime' repository. after fixing this the files appeared to add correctly. I then ran 'git push hub master' and there now appear to be files in the site_hub.git/objects/pack directory which I assume are the pushed files. Once again thank you for your help , I am going to continue to follow the articles directions, and I'll open a new question if I can't figure something else out. Regards, - Bill – user1592380 Nov 19 '12 at 07:47
  • @user61629 No problem, I am glad you made it work in the end :) I would still recommend a git push -u hub master instead of a git push hub master though: that *upstream* tacking link is important. I have edited the answer to reflect your conclusion for more visibility. – VonC Nov 19 '12 at 07:52