Working with git repositories

  • Posted on: 20 November 2015

Initialize bare git repository

Use these commands to initialize a bare (empty) git repository. This is usualy a good idea when you want to create a central repository.

mkdir /var/git-repo/project.gif
cd /var/git-repo/project.gif
git init --bare

Configure git groups and users

Also make sure that the developers will have access to the repo. This can be done by adding them to a group developers and giving permissions to the git repository directory.

If the developers group does not exist yet, you can create it with this command:

groupadd developers

Then add the user to this group

useradd -G developers username


usermod -a -G developers username

Give access to the repository with this command:

sudo chown -R root.developers project.git
sudo chmod -R g+w project.git/

Work with local git repository

After that you need to create a local git directory with git init. From that one you can do:

git init

Add remote repository to your local:

git remote add origin

If you make a mistake you can remove invalid remote origins with this command:

git remote rm origin

Do some work and:

git add .
git commit -m "Initial import"
git push origin master

The repository will be avaibale to your co-developers and can be cloned to their own local git repo.

git clone

Check also this page: