Feb
13
2011

Hosting your git repo on your own server

Hosting a git repo yourself is a very simple exercise. If you don’t need (or don’t want to pay for) features offered by github, you can setup your server to host your git repo. All you need is a server with ssh access. Here are the steps that you need to follow

Login to your server


ssh tom@example.com
tom@example.com$ mkdir my_repo.git
tom@example.com$ cd my_repo.git
tom@example.com$ git init

On you local machine, where you have your code


$ cd my_code # cd to your code
$ git init
$ git add . # Adds everything. Use .gitignore to ignore some files
$ git remote add origin tom@example.com:my_repo.git
$ git push origin master

Now you can clone tom@example.com:my_repo.git on any number of machines. To not share password, put your public keys on tom@example.com

This approach gives you a basic git setup with ssh access (no http access). These steps should work on shared hosting too (as long as you have git available)

posted in Uncategorized by prateek

Follow comments via the RSS Feed | Leave a comment | Trackback URL

3 Comments to "Hosting your git repo on your own server"

  1. Swanand wrote:

    Hi Prateek,

    I think you probably need this on the remote server:

    git config –bool core.bare true

    Regards,
    Swanand

  2. Swanand wrote:

    i.e. while running for the first time

  3. prateek wrote:

    Hmm .. not sure … I don’t think I needed this

    Nevertheless, thanks for the comment. It may save someone some trouble :)

Leave Your Comment

 
Powered by Wordpress and MySQL. Theme by openark.org