GitのローカルリポジトリをNAS上に作成する
単純に、ファイルシステム上にリポジトリを作るのと同じ。
ただし、ユーザー違いの問題がある。(直接ファイルを更新することになるが、ユーザー権限で更新したくても更新できないことがある。)
このため、本気で使いたいならちゃんとGitリポジトリサーバーを立てるのが望ましい。
Windows の場合
NAS上にリポジトリ用のベースフォルダを作成
git_repo
プロジェクトのフォルダを作成
git_repo/myproj
プロジェクトのフォルダ上で右クリックで Git Bash を選択
念のためディレクトリを確認。プロジェクトのフォルダの中であることを確認
$ pwd
(PowerShell でも、cd \\NASドライブ名\NASフォルダ\リポジトリベースフォルダ...\プロジェクトフォルダ のように指定すればよい。)
$ git init
これでリポジトリのひな型ができる。
クローンするとき
$ git clone file:////NASドライブ名/NASフォルダ/リポジトリベースフォルダ/プロジェクトフォルダ
file:// を付けないと、ファイルオーナーが同一ユーザーでない場合に以下のようなエラーが出る。
code:console
git clone //nas.local/data/git_repo/myproj
Cloning into 'myproj'...
warning: You appear to have cloned an empty repository.
fatal: detected dubious ownership in repository at '//nas.local/data/git_repo/myproj/.git'
'//nas.local/data/git_repo/myproj/.git' is owned by:
(inconvertible) (S-1-5-21-aaaaaaaaa-aaaaaaaaaa-aaaaaaaaaa-aaaa)
but the current user is:
MYMACHINE/user (S-1-5-21-bbbbbbbbb-bbbbbbbbbb-bbbbbbbbbb-bbbb)
To add an exception for this directory, call:
git config --global --add safe.directory //nas.local/data/git_repo/myproj/.git