gitの共有リポジトリ

gitの操作が覚えられないので、書くことにした。
参考:http://blog.s21g.com/articles/1312

サーバでの操作(共有リポジトリを作成)

$ mkdir expample.git
$ cd example.git/
$ sudo git init --bare --shared

共有リポジトリを作成する際は、通常"--bare --shared""オプションをしていする。
"--bare"を使うとgitの管理情報(通常は.gitに入るもの)がexpample.gitに直接展開される。"--bare"を指定する場合は、慣習的に<フォルダ名>.gitと命名する。
"--shared"でグループのアクセス権限を読み書き可能に設定できる。


ローカルマシンでの操作

$ git remote add origin ssh://<ユーザ名>@<アドレス>/xxx/xxx/expample.git
$ git push origin master

でサーバにpush。

remote add で間違っちゃったら

$ git remote -v
origin	ssh://<ユーザ名>@<アドレス>/xxx/xxx/expample.git(fetch)
origin	ssh://<ユーザ名>@<アドレス>/xxx/xxx/expample.git(push)
$ git remote rm origin

てなかんじで削除する。


サーバからcloneするときは

$ git clone ssh://<ユーザ名>@<アドレス>/xxx/xxx/expample.git

サーバから変更を取得するときは

$ git fetch ssh://<ユーザ名>@<アドレス>/xxx/xxx/expample.git
$ git diff FETCH_HEAD
$ git merge FETCH_HEAD

という感じ。


アリスとボブのGit入門レッスン

アリスとボブのGit入門レッスン