Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to install git on a Ubuntu server that will be shared and accessed by multiple users.

I assume I will use git+ssh, so each user will have a system account, but how do I go about installing git and a repository so that each user can push/pull over a local IP?

share|improve this question

I would recommend using gitolite for managing user access and permissions.

Best way to describe it is to cite the developer:

Gitolite lets you use a single user on a server to host many git repositories and provide access to many developers, without having to give them real userids on or shell access to the server. The essential magic in doing this is ssh's pubkey access and the authorized_keys file, and the inspiration was an older program called gitosis.

Gitolite can restrict who can read from (clone/fetch) or write to (push) a repository. It can also restrict who can push to what branch or tag, which is very important in a corporate environment. Gitolite can be installed without requiring root permissions, and with no additional software than git itself and perl. It also has several other neat features described below and elsewhere in the doc/ directory.

And here is some features I personally would like to highlight:

  • Each user is forced to have a SSH key, or else they can't push to the server
  • No system accounts - just a 'git' user on the server.
    • you do all your git interactions with your server through this user
  • Configuration and addition of SSH keys happens through a git repo!
    • for instance when creating a repo you just add two lines to your gitolite config, name of the repo and who has permissions to read/write to it. Commit and push, and vóila! you can now clone your fresh empty repo using 'git clone ssh://'.

Good luck


share|improve this answer

One way to do this is to create a group for the "git" users and add all the users who you would like access to this group. You can use the "groupadd" command to create the group, then I just edit /etc/group to modify the comma-separated list of users in that group. I usually name the group based on project, like "newwebsite" rather than something like "git". For example, the /etc/group entry may look like:


Now, create a directory to hold the git repository, say "/var/git/newwebsite": mkdir -p /var/git/newwebsite

Set up the permissions on this directory to include group sticky bit:

chgrp newwebsite /var/git/newwebsite
chmod g+ws /var/git/newwebsite

Now initialize the repository in this directory with:

cd /var/git/newwebsite
git init --bare --shared=group

NOTE: Do not replace "group" with your group, it needs to be the literal string "group".

If this errors out, your version of "git" probably doesn't support the "--bare" option. Remove the "--bare" option in that case.

At this point, your users should be able to check out the repository with:

git clone git+ssh://$USER@$HOST/var/git/newwebsite
share|improve this answer

To install git on Ubuntu

sudo apt-get install git-core

For instructions on how to use it have a look at this document which I have found an excellent reference.

share|improve this answer
The question, as I read it, is more about how to configure a git repository for shared user access than about installing the package. – Sean Reifschneider Nov 14 '10 at 22:52
I think you're being a little harsh in presuming to be ably to read the OP's mind from some weeks into the past. My answer answers the question as asked, is correct, and provides a link to additional information that the OP could use to learn more about the subject. – Iain Nov 17 '10 at 12:17
I didn't intend to be harsh, just saying that the way I read the question (not anyone's mind :-) was that it was about much more than just "apt-get install git-core". Sorry... – Sean Reifschneider Nov 25 '10 at 1:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.