Create a Git Server

The best way to collaborate with someone is to create an intermediate repository to both send and download data. We will refer to this repository as a “Git server”.

Create a Git server is quite simple.

To initialize any Git server, you must export an existing repository to a new data-only repository (a repository that does not contain the work directory).

To create a new data-only repository, open a linux shell on your local system and type something like:

git clone –bare awesome-project awesome-project.git

In this example we are cloning a project called “awesome-project”.

Conventionally, a data-only repository is “*.git”.

Now we have a clone of data directory in “awesome-project.git” directory.

Now you can copy the “bare” directory on the server machine, where you have an ssh access.

For example, the server has name “” (ehya!) and we want to put the repository under “/var/www/git” directory.

On your local terminal, just type:

scp -r awesome-project.git

Now all the users that have an ssh access on server can clone the repository via the command:

git clone

If users have write permissions to the /var/www/git/awesome-project.git directory, they can also send data.

Git automatically adds write permissions to the repository to the group using “shared” option on git init.

cd /var/www/git/awesome-project.git
git init –bare –shared

That’s all folks! This is all is needed to start a Git server where multiple users have access.


Soon we’ll discuss how to manage a more complex environment (e.g. public key mangament, public read access to repositories, Gitosis, Gitolite, and so on).

Leave a comment

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