Skip to main content
  1. Notes/
  2. git/

Shared

183 words

Warning

this is a dumb way to do it in my very humble opinion.

There is a way to have git set a setuid bit on the archive to make it shareable with other users.

Initialise the archive:

[user1@servername ~]$ git init --bare --shared=true  /srv/shared/BAR.git
Initialized empty shared Git repository in /srv/shared/BAR.git/

Clone the archive:

[user1@servername ~]$ git clone /srv/shared/BAR.git
Cloning into 'BAR'...
warning: You appear to have cloned an empty repository.
done.

Add a target to the archive:

[user1@servername ~]$ cd BAR/
[user1@servername BAR]$ echo "Hello" >README.txt
[user1@servername BAR]$ git add README.txt
[user1@servername BAR]$ git commit -m "initial version" README.txt
[master (root-commit) c8bdd40] initial version
 1 file changed, 1 insertion(+)
 create mode 100644 README.txt

Push the results:

[user1@servername BAR]$ git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 236 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /srv/shared/BAR.git
 * [new branch]      master -> master

Login as user2 and check out the archive:

[user2@servername ~]$ git clone /srv/shared/BAR.git
Cloning into 'BAR'...
done.
[user2@servername ~]$ cd BAR/
[user2@servername BAR]$ ls
README.txt

Or:

[user2@servername ~]$ git clone ssh://servername/srv/shared/BAR.git