Git: Easy way to setup a private remote repository 9 comments
Git is different from svn and create a private repository on a remote server too. No need of gitosis or git-daemon for this.
I start from an existing project and a server I already access to with ssh key.
First, initialize git in your project:
git init
git add .
git commit -m 'initial import'[update]
Then create a git copy of your project into a git archive my_project_folder.git.
git clone—bare my_project_folder my_project_folder.git
Copy this archive the .git folder to your remote server:
scp -rp .git user@server://path/to/repositories/my_project_folder.gitAdd this new repository in the config of your local project:
git remote add my_remote_repo ssh://server/path/to/repositories/my_project_folder.gitYou’re done. After a change you can commit and then push your change to the remote repo:
git commit -m "message for change log"
git push my_remote_repoUse your own parameters for:
- my_project_folder with the folder of your project
- path/to/repositories with the path to your repository on the remote server
- my_project_repo with the name you want for the remote repository, usually origin
If you need a public repository, have look to gitosis or git-daemon. Best is Github.





Call me old fashioned…. But I still haven’t found any reason for why I should move to git from Subversion. I have no need for local repos since I’m always network connected. The easy branching would be nice but really isn’t a must for me. But I would miss all the tools that would be missing.
And I keep hearing about how amazing it is to have many repositarys for the code. But I haven’t really heard why it would be an advantage. Unless you have 20+ developers on the project working on the same code. And that’s not common.
This post is more about using git than moving from svn to git. But for my own experience, I did move to git because it’s much faster and open new ways of social collaboration, as you can see on Github. Also I’d prefer to make several local commits and then a bigger commit to a central repo rather than always push small changes to the repo, and I m not always connected. A last point, git is pretty well integrated in Textmate now.
Being said, people are free to use whatever SCM they like :)
Hey I’m not judging. ;)
After watching the Peepcode screencast I decided not to go to Git. Just seemed to overly complicate things somehow when most users just simply need to know the “svn add” and “svn commit” commands and they are good for life. :)
You’re right, the learning curve is harder with git than with svn and for new users it’s not simplifying life, at first. That’s why I published this post to show an “easy” way of using git. Currently I only use clone, commit, and push.
How come you cloned your initial project? I usually just:
scp -r .git ssh://remotehost:new_repo.git
Then go from there.
Ok, thanks for the comment.
Should it even be:
scp -r .git remotehost:new_repo.gitDon’t forget that your remote host has to have Git installed for this to work.
Yeah, it should ;)
Jon Gretar, you should maybe checkout Mercurial (Hg), there’s even a TortoiseHg project. It’s a really great SCM (and fast)