massa snap

massa の備忘録

Bitbucket でプライベート git リポジトリを作ってみる

ローカルのgitリポジトリを、非公開で共有してみたくなった。

を見ると、Assembla か Bitbucket がよさげ。
後者は git 以外に Wiki の利用もできるらしいので、そちらを利用してみることに。

1. アカウント作成 〜 リポジトリ作成

2. リポジトリへのSSHアクセス準備

 $ ssh-keygen -t rsa
 Generating public/private rsa key pair.
 Enter file in which to save the key (/Users/<user>/.ssh/id_rsa): /Users/<user>/.ssh/id_rsa_<project>
     (略)
 $ ssh-add /Users/ayumin/.ssh/id_rsa_<account>
  • ~/.ssh/config に以下の設定を追加
# bitbucket user for "<account>"
Host gitrepo-<account>
  User git
  Port 22
  Hostname bitbucket.org
  IdentityFile ~/.ssh/id_rsa_<account>
  TCPKeepAlive yes
  IdentitiesOnly yes
  • bitbucket 側に RSA 公開鍵を登録
    1. bitbucket のアカウント設定画面から、[SSH Keys] を選択
    2. [SSH Key] 欄に、指示通り id_rsa_.pub の内容をコピーして、[Add key] を押下

3. リポジトリへのコード登録

$ cd /path/to/repo
$ git remote add origin git@gitrepo-<account>:<account>/<project>.git
$ git push origin master