コスギデンサン > 情報系メモ > GIT

GIT : リポジトリ作成 2016/12

サーバ側:ベアリポジトリの作成
$ mkdir project1.git
$ cd project1.git
$ git --bare init
Initialized empty Git repository in /path/to/project1.git/
$ ls
branches config description HEAD hooks info objects refs
※ gitベアリポジトリ用ディレクトリは慣習的に名前の最後を.gitとする。

クライアント側:リポジトリの作成とソースのコミット
$ mkdir project1_local 
$ cd project1_local
$ git init
ソースコードのコピー
$ copy path_to_src .
$ git add .
$ git status -s
$ git commit -m "Initail commit"
※ この時点ではローカルリポジトリにコミットされる。

クライアント側:リモートへのプッシュ
$ cd project1_local
$ git remote add origin http://git.kd2.git/project1.git
$ git push origin master
※ リモートリポジトリ名は慣習的にoriginとする。
登録したリモートリポジトリの確認。
$ git remote -v

クライアント側:リモートからクローン
$ git clone  http://git.kd2.git/project1.git (dest_name)
※ (dest_nameを指定しない場合は)実行ディレクトリにproject1というローカルディレクトリが作成される。
 masterブランチのみコピーされ、他のブランチはコピーされない。