Skip to content

Instantly share code, notes, and snippets.

@ktx2207
Last active August 29, 2015 14:05
Show Gist options
  • Save ktx2207/f12fe2a3c12e1e3f943d to your computer and use it in GitHub Desktop.
Save ktx2207/f12fe2a3c12e1e3f943d to your computer and use it in GitHub Desktop.
Git - ベアリポジトリ作成

Git - ベアリポジトリ作成

####リモートでベアリポジトリ作成

$ mkdir -p git/bare/repo.git  
$ cd git/bare/repo.git  
$ git --bare init --share  

####ローカルでノンベアリポジトリを作成

$ mkdir repo  
$ git init  
$ git add .  
$ git commit -m 'first commit' 

####ローカルでリモートリポジトリを登録

$ git remote add origin ssh://username@remote_server/git/bare/repo.git

※ この操作で"ssh://username@remote_server/git/bare/repo.git"の識別子がoriginになる。

####ローカルリポジトリの内容をリモートリポジトリへ送信

$ git push -u origin master

※originは"ssh://username@remote_server/git/bare/repo.git"を指す。
-uを指定すると今後、git pushと指定するだけでoriginリポジトリにmasterブランチをpushするようになる。
また、git pullと指定するだけでoriginリポジトリのmasterブランチから取得するようになる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment