Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a folder called my-project inside which I've done git init, git commit -a, etc.

Now I want to push it to an empty folder at /mnt/foo/bar on a remote server.

How can I do this?

I did try, based on what I'd read:

cd my-project
git remote add origin ssh://user@host/mnt/foo/bar/my-project.git
git push origin master

which didn't seem right (I'd assume source would come before destination) and it failed:

fatal: '/mnt/boxee/git/midwinter-physiotherapy.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

I'd like this to work such that I don't have to access the remote host and manually init a Git repository every time ... do I have to do that? Am I going down the right route at all?

Thanks.

share|improve this question

2 Answers 2

up vote 20 down vote accepted

The command is correct; however, the remote address must point to an initialized Git repository too. It's a one-time job, though.

ssh user@host "git init --bare /mnt/foo/bar/my-project.git"

(In Git, a "bare" repository is one without a working tree.)

share|improve this answer

If you don't want to create the repository manually on the server, you could install gitosis, which will automate the process. But you have to have some process on the server to create the repository -- you can't do it over a git ssh connection from the client.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.