Git : Create Shared Repositories2023/07/25 |
Create Shared Repositories which some users can use.
|
|
[1] | Create a group for share and set users in the group. |
# add users to the group root@dlp:~# usermod -aG project01 debian root@dlp:~# usermod -aG project01 bookworm
|
[2] | Create a shared repository with a user. |
# create a directory for repository and change group debian@dlp:~$ mkdir project01.git debian@dlp:~$ chgrp project01 project01.git debian@dlp:~$ cd project01.git
debian@dlp:~/project.git$
chmod 755 /home/debian # set empty share repository debian@dlp:~/project.git$ git init --bare --shared hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> Initialized empty shared Git repository in /home/debian/project01.git/ # with [--shared] option, SGID is set like follows debian@dlp:~/project.git$ ll -d /home/debian/project01.git drwxrwsr-x 7 debian project01 4096 Jul 24 20:02 /home/debian/project01.git |
[3] | Verify to use repository with users who are in the group for share added in [1]. |
bookworm@node01:~/work$ git init hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> Initialized empty Git repository in /home/bookworm/work/.git/
bookworm@node01:~/work$
git config --global user.name "Server World" bookworm@node01:~/work$ git config --global user.email "bookworm@dlp.srv.world"
# create a test file and push it to repository bookworm@node01:~/work$ echo testfile > testfile1.txt bookworm@node01:~/work$ git add testfile1.txt bookworm@node01:~/work$ git commit testfile1.txt -m "Initial Commit" [master (root-commit) d20f3c3] Initial Commit 1 file changed, 1 insertion(+) create mode 100644 testfile1.txtbookworm@node01:~/work$ git remote add origin ssh://bookworm@dlp.srv.world/home/debian/project01.git bookworm@node01:~/work$ git push origin master bookworm@dlp.srv.world's password: Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 234 bytes | 234.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To ssh://dlp.srv.world/home/debian/project01.git * [new branch] master -> master |
Sponsored Link |