Tutorial: share a local git repository

Share a bare git repository with git-core without any server:

  1. Create folder and change group ownership (and add two users to the group)

    mkdir /data/git/myrepository.git
    chgrp devgroup /data/git/myrepository.git
    
    adduser dev1 devgroup
    adduser dev2 devgroup
  2. Initialize git repository

    Allows read and write access to the user, and read-only access to the group (and no access to other):
    git init --bare --shared=0640 /data/git/myrepository.git
    
    Allows read and write access to the user and to the group (and no access to other):
    git init --bare --shared=0660 /data/git/myrepository.git
    
    Allows read and write access to the user and group, and read-only access to other:
    git init --bare --shared=0664 /data/git/myrepository.git
    
  3. Configure your project to be part of the shared repository

    cd ~/MyProject
    git init
    git add --all
    git commit -m “Initial commit of my project."
    

    Add remote origin repository:

    git remote add origin ssh://[email protected]/data/git/myrepository
    
  4. Set default push to remote and push to the remote repository

    git push --set-upstream origin master
    
  5. Later push to origin repository

    git push