setting up a git repository

On the server
  1. Install git:
    user@server:~$ sudo apt-get install git
  2. Create a user git (see here).
  3. Generate a key pair for password-less login for the git user (see here)
  4. Set the user’s shell to git-shell
    1. Change etc/passwd from something like this:
      [...]
      git:x:1001:1001:,,,:/home/git:/bin/false
      [...]
      to something like this:
      [...]
      git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
      [...]
      (assuming git userid is 1001, git groupid is 1001 and git home is /home/git)
    2. Append to /etc/shells: /usr/bin/git-shell. It should look something like this:
      [...]
      /usr/bin/git-shell
      [...]
  5. Create the repository:
    user@server:~$ mkdir repository.git
    user@server:~$ cd repository.git
    user@server:~$ git init --bare
On the client
  1. Clone the repository:
    user@client:~$ git clone git@server-adress:/home/git/repository.git
  2. Done!
Usage info Everyone pushing and pulling to/from this repository will require the ssh key created in step 3. Note that the unix user git was created only for accessing the server, a committer’s ID is actually defined in ~.gitconfig.
Share itShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *