Git set up a public repository

If you have to set up a public repository with git you can follow the instruction found on the git-core tutorial
(Hint: Search for “Publishing your work”)

Things to keep in mind:

  • Public repository are usually named as project.git and it’s a directory even if you can be mislead to think it’s a file for the extension (.git). Well, it’s not a file.
  • you need to login in the remote host (the one from which you will share your repo) and initialized a local git database:
    • ssh account compulsory
    • git should be in the path and available in the web server
  • You need an ssh account over there.
  • Then you can push your changes to the new shiny repo.

The steps to do that:

  1. login the remote <public-host>
  2. mkdir project.git
  3. GIT_DIR=my-git.git git init
  4. mv project.git/hooks/post-update.sample project.git/hooks/post-update This make sure that after every push the git update-server-info is ran and your repo can be accessed in the public way.
  5. git push <public-host>:/path/to/project.git master

1 Comment

  1. Thank you, this is interesting.
    I have tried to set up a common repository for all us in my group, but in the end I have decided to use github and a paid account.

Leave a Reply