CentOS 8
Sponsored Link

Git : 共有リポジトリを作成する2020/04/14

 
複数ユーザーで利用可能な共有リポジトリを作成します。
[1] 共有用のグループを作成して、共有リポジトリを使用予定のユーザーを全て所属させておきます。
# 任意のグループ作成

[root@dlp ~]#
groupadd project01
# 作成したグループにユーザー追加

[root@dlp ~]#
usermod -aG project01 cent

[root@dlp ~]#
usermod -aG project01 redhat
[2] 共有用のグループに所属させた任意の一般ユーザーで共有リポジトリを作成します。
# 共有リポジトリ用のディレクトリを作成して準備した共有用グループに変更

[cent@dlp ~]$
mkdir project.git

[cent@dlp ~]$
chgrp project01 project.git

[cent@dlp ~]$
cd project.git
[cent@dlp project.git]$
chmod 755 /home/cent

# 共有用の空リポジトリを作成

[cent@dlp project.git]$
git init --bare --shared

Initialized empty shared Git repository in /home/cent/project.git/
# [--shared] オプションを付加して作成すると SGID がセットされる

[cent@dlp project.git]$
ll -d /home/cent/project.git

drwxrwsr-x. 7 cent project01 119 Apr 10 17:04 /home/cent/project.git
[3] [1] で共有用のグループに所属させた任意の一般ユーザーで確認します。
[redhat@node01 ~]$
mkdir work

[redhat@node01 ~]$
cd work
[redhat@node01 work]$
git init

Initialized empty Git repository in /home/redhat/work/.git/
[redhat@node01 work]$
git config --global user.name "Server World"

[redhat@node01 work]$
git config --global user.email "redhat@dlp.srv.world"
# テストファイルを作成してリポジトリに反映

[redhat@node01 work]$
echo testfile > testfile1.txt

[redhat@node01 work]$
git add testfile1.txt

[redhat@node01 work]$
git commit testfile1.txt -m "Initial Commit"

[master (root-commit) 676cfe2] Initial Commit
 1 file changed, 1 insertion(+)
 create mode 100644 testfile1.txt

[redhat@node01 work]$
git remote add origin ssh://redhat@dlp.srv.world/home/cent/project.git

[redhat@node01 work]$
git push origin master

redhat@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)
To ssh://dlp.srv.world/home/cent/project.git
 * [new branch]      master -> master
関連コンテンツ