お疲れ様です。
タイトルの通り、共有ファイルサーバでGit管理する方法を備忘として残しておきます。
権限の関係で、clone出来ない状況を経験したので、その場合の回避方法も記載します。(あくまで私の解決方法なので、すべての方に適応するとは限りませんので悪しからず)
※前提:Gitクライアントは各人のPCにインストールされていること
→「git for windows」入れましょう。
その1
シンプルにbareリポジトリのみを作成。
プロジェクト開始時に誰かがbareリポジトリを以下手順で作成します。
リモート(中央)リポジトリとして管理したいディレクトリを「current/remote.git」とします。
リモートに乗せたいプロジェクトのディレクトリを「current/local」とします。
- リモートリポジトリとするディレクトリに、bareリポジトリを作成
- ReadMeをcommit、pushしておく
- 第三者がcloneする
- 終わり
$ pwd
// current/remote.git
$ git init --share --bare // 中央リポジトリを作成
$ cd current/local
$ git init // リポジトリ作成
// ReadMe作成してコミットまで実行
$ touch ReadMe.md
$ git add .
$ git commit -m "first commit"
// localリポジトリからremoteリポジトリを設定しpush
$ git remote add origin current/remote.git
$ git push origin master
// 第三者がcloneする
$ git clone /current/remote.git
その2
別の環境で同様の手順を試みたのですが、第三者がcloneする際にエラーにより実行できなかった時のやり方です。
中央リポジトリを「current/bare.git」
リモートに乗せたいプロジェクトのディレクトリを「current/nonbare」とします。
どちらも、ファイルサーバー上のパスになります。
- ファイルサーバー上にnonbareリポジトリを作成
- nonbareリポジトリに1commitしておく
- ファイルサーバー上から、1で作成したnonbareリポジトリをbareリポジトリとしてclone
- 以下同じ
$ pwd
// current/nonbare
$ git init
$ touch ReadMe.md
$ git add .
$ git commit -m "first commit"
$ pwd
// current/bare.git
$ git clone --bare current/nonbare
// 第三者がcloneする
$ git clone current/bare.git
その2の場合は、hooks作成して、bareリポジトリのmasterにpushされた時に自動で、nonbareにも更新を反映させられると後ほど(多分)便利だと感じる時が来ます。
終わりに
ざっと備忘を残しました。誤った認識の箇所あるかもしれませんが、運用は問題なく行えています。日々精進して、正しい構成が判明次第記事をブラッシュアップしていきます。