Reputation: 1952
I started using GitHub this weekend for a new personal project (we also use git at work) and their tutorial has me do the following:
$ mkdir ~/Hello-World
$ cd ~/Hello-World
$ git init
$ touch README
Then after I add my initial commit I add the origin and then can just push:
$ git remote add origin [email protected]:username/Hello-World.git
$ git push origin master
Usually, I have to zip up a new repo, copy it to my server, and then perform a git clone --bare
in order to start pushing to it. How is it that they are able to skip this step?
Upvotes: 2
Views: 226
Reputation: 85496
It's enough to create an empty repository on the server and after that you can push your repo to it.
UPDATE: as VonC pointed out the new repository must be bare to do so. I was unaware of that since I use gitolite to create repositories and I suppose that it creates bare ones.
Configuration example for a gitolite repo:
repo adir/myrepo
RW+ = user1
RW+ = user2
R = user3
So to create a repo with gitolite I just add a configuration like that in conf/gitolite.conf and then commit and push the changes. I edit on my laptop, the push goes to the server and triggers the repo creation. Very comfortable.
Upvotes: 0
Reputation: 42677
There's no need to zip up the repo and copy it to your server. Just run git init --bare
to create the bare repo first on your server and then you could push, just like you can with github.
Upvotes: 0
Reputation: 1324947
The repo on GitHub is already a bare one, so you can start pushing directly.
(As illustrated on "Setting up backup (mirror) repositories on GitHub")
More on bare repo in this "all about "bare" repos -- what, why" documentation.
Upvotes: 3