Allowing multiple users to pull from a git repository on a shared server

A pretty common situation. Multiple developers working together on their local development machines and connecting to a central git repository with their own credentials. And there’s a dev/staging server where all users need to to have access to go login and pull the code. When you clone the git repository on the server, it essentially sets it up as the user who set it up and doesn’t allow other users to pull the code. Here’s how the config looks like:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = ssh://varun.verma@server.path.net/var/git/project_repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "dev"]
        remote = origin
        merge = refs/heads/dev
[branch "task/upgrading_django"]
        remote = origin
        merge = refs/heads/task/upgrading_django

And the user can pull the repository using git pull

Now, in order to configure the repository so that all users who have access to the server are able to pull the code, here’s how the configuration should look like:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = nouser@server.path.net/var/git/project_repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "dev"]
        remote = origin
        merge = refs/heads/dev
[branch "task/upgrading_django"]
        remote = origin
        merge = refs/heads/task/upgrading_django
[remote "varun.verma"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = varun.verma@server.path.net:/var/git/project_repo.git
[remote "other.user"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = other.user@server.path.net:/var/git/project_repo.git

And pull the repository by executing sudo git pull varun.verma task/upgrading_django. The system would ask for your local server password to sudo followed by the password for the remote git repository. This should resolve the problem.

Advertisements
Posted in GIT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s