SynologyのNAS(DS218play)上にGitリポジトリを作成する

Synology

SynologyのNASであるDS218play上に構築したGitサーバー上にリポジトリを新規作成してWSL上のUbuntuからクローンする手順について説明する。

NAS(DS218play)上にGitサーバーを構築する

まずはNAS上にGitサーバーを構築する。
こちらの記事を参考にしてください。

NASにSSHでログインしてGitリポジトリを新規作成する

  1. NASにSSHで接続しログインする(RLoginの例をGitサーバー構築の記事に記載)
  2. git initコマンドでリポジトリを作成する
  3. SSHを切断する
$ cd volume1/gitvolume/
$ git --bare init --shared sample.git
Initialized empty shared Git repository in /volume1/gitvolume/sample.git/

WSL上のUbuntuでリポジトリをクローンする

例としてWSL上のUbuntuでクローンする例を記載する。

  1. WSLを起動する
  2. git clone コマンドでクローンする
git clone ssh://<username>@<ip address or hostname>/volume1/gitvolume/sample.git

以下はコマンドと出力の具体例です。
ユーザー名はGitサーバー構築時に作成したgituserを使用した。
IPアドレスの箇所はホスト名としてもよい
パスワードの入力を促されるのでパスワードを入力する必要がある。

$ git clone ssh://gituser@192.168.10.8/volume1/gitvolume/sample.git
Cloning into 'sample'...
gituser@192.168.0.18's password:
Could not chdir to home directory /var/services/homes/gituser: No such file or directory
warning: You appear to have cloned an empty repository.

以上でNAS上に構築したGitサーバー上にリポジトリを作成してこれをクローンすることができた。

コメント

タイトルとURLをコピーしました