Git : 共有リポジトリを作成する2022/09/27 |
複数ユーザーで利用可能な共有リポジトリを作成します。
|
|
[1] | 共有用のグループを作成して、共有リポジトリを使用予定のユーザーを全て所属させておきます。 |
# 作成したグループにユーザー追加 root@dlp:~# usermod -aG project01 ubuntu root@dlp:~# usermod -aG project01 jammy
|
[2] | 共有用のグループに所属させた任意の一般ユーザーで共有リポジトリを作成します。 |
# 共有リポジトリ用のディレクトリを作成して準備した共有用グループに変更 ubuntu@dlp:~$ mkdir project.git ubuntu@dlp:~$ chgrp project01 project.git ubuntu@dlp:~$ cd project.git
ubuntu@dlp:~/project.git$
chmod 755 /home/ubuntu # 共有用の空リポジトリを作成 ubuntu@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/ubuntu/project.git/ # [--shared] オプションを付加して作成すると SGID がセットされる ubuntu@dlp:~/project.git$ ll -d /home/ubuntu/project.git drwxrwsr-x 7 ubuntu project01 4096 Sep 23 07:35 /home/ubuntu/project.git/ |
[3] | [1] で共有用のグループに所属させた任意の一般ユーザーで確認します。 |
jammy@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/jammy/work/.git/
jammy@node01:~/work$
git config --global user.name "Server World" jammy@node01:~/work$ git config --global user.email "jammy@dlp.srv.world"
# テストファイルを作成してリポジトリに反映 jammy@node01:~/work$ echo testfile > testfile1.txt jammy@node01:~/work$ git add testfile1.txt jammy@node01:~/work$ git commit testfile1.txt -m "Initial Commit" [master (root-commit) fa6144f] Initial Commit 1 file changed, 1 insertion(+) create mode 100644 testfile1.txtjammy@node01:~/work$ git remote add origin ssh://jammy@dlp.srv.world/home/ubuntu/project.git jammy@node01:~/work$ git push origin master jammy@dlp.srv.world's password: Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 233 bytes | 233.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To ssh://dlp.srv.world/home/ubuntu/project.git * [new branch] master -> master |
Sponsored Link |
|