0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Git環境構築

0
Last updated at Posted at 2023-03-20

Cent OSでの環境構築手順

1.gitをインストール

yum install git

2.sshをインストール

yum install openssh-server

3.ユーザ作成

#ユーザグループの追加(削除はgroupdel)
groupadd gitgroup
#追加されたグループの確認
cat /etc/group 
gitgroup:x:[groupID]:

#git用ユーザ作成(削除はuserdel)
useradd -u [userID] -g [groupID] [username]
#例
useradd -u [userID] -g [groupID] gituser

#作成ユーザーの確認
cat /etc/passwd
xxxx:x:[userID]:[groupID]::/home/[username]:/bin/bash
#例
xxxx:x:[userID]:[groupID]::/home/gituser:/bin/bash

#ユーザID,所属グループ確認
id [userID]
uid=[userID]([username]) gid=[groupID](gitgroup) 所属グループ=[groupID](gitgroup)

#パスワードの設定
passwd [userID]
[password]

4.格納ディレクトリ作成

mkdir /mnt/drive1/git-server
#ユーザ所有権、グループ所有権を変更
chown gituser:gitgroup /mnt/drive1/git-server

5.リポジトリの場所を作成

mkdir /mnt/drive1/git-server/sample1-rep.git

6.初期設定

#※オプションの意味
#--bare:最小限のリポジトリを作成する。もしGIT_DIR環境が設定されていなければ、現在のワーキング・ディレクトリが設定される。
#--shared:Gitリポジトリが複数のユーザで共有されることを指定する。このオプションは、同じグループに属するユーザがそのリポジトリにpushすることを許可する。
[gituser@CentOS7 ~]$ cd /mnt/drive1/git-server/sample1-rep.git/
[gituser@CentOS7 rep.git]$ git init --bare --shared
Initialized empty shared Git repository in /mnt/drive1/git-server/sample1-rep.git/

7.確認

[gituser@CentOS7 ~]$ ls -la /mnt/drive1/git-server/sample1-rep.git/
合計 16
4 -rw-rw-r--. 1 gituser gitgroup 23 5月 10 16:07 HEAD
0 drwxrwsr-x. 2 gituser gitgroup 6 5月 10 16:07 branches
4 -rw-rw-r--. 1 gituser gitgroup 126 5月 10 16:07 config
4 -rw-rw-r--. 1 gituser gitgroup 73 5月 10 16:07 description
4 drwxrwsr-x. 2 gituser gitgroup 4096 5月 10 16:07 hooks
0 drwxrwsr-x. 2 gituser gitgroup 20 5月 10 16:07 info
0 drwxrwsr-x. 4 gituser gitgroup 28 5月 10 16:07 objects
0 drwxrwsr-x. 4 gituser gitgroup 29 5月 10 16:07 refs

Windows側設定

1.git for windowsをダウンロードしてインストール

2.tortoisegitをダウンロードしてインストール

3.gitクライアント用のフォルダを作成

C:\Users\user1\Documents\git-client

4.サーバーと紐づけ

C:\Users\user1\Documents\git-client』を右クリック
Git clone..』を選択
URL』に
ssh://gituser@xxx.xxx.xxx.xxx/mnt/drive1/git-server/sample1-rep.git
『OK』ボタン
パスワード画面にgituserのパスワードを入力
『show log』または『close』

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?