戻る

目次

Bitbucketとは

  • Free source code hosting for Git and Mercurial by Bitbucket
    「Mercurial」または「Git」のリモートリポジトリを管理できるホスティングサービス
    無料のアカウントでプライベートリポジトリを無制限に生成する事が出来、同時に5ユーザーまで使用する事が出来ます
    ※別途有料プランもあります

秘密鍵・公開鍵を作る

Bitbucket との通信を暗号化するために、秘密鍵・公開鍵を作成する必要があります。

1.OpenSSHの秘密鍵・公開鍵を作成

  1. デスクトップにある[Git Bash]ショートカットをクリック
  2. 以下のコマンドを実行
    ssh-keygen -t rsa
  3. 以下の様にファイル名を聞いてくるのでEnterを押す
    ※表示されているフォルダにid_resという名前で生成される
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/(ユーザーID)/.ssh/id_rsa):
    ※ここで好きなファイル名を入力する事が出来ますが、そうした場合は何故か「.ssh」フォルダが作られません
  4. 鍵を使うためのパスワードを設定する
    ※ここで設定したパスワードは後で何度も使うのでメモして下さい
    Enter passphrase (empty for no passphrase):
  5. もう一度同じパスワードを入力する
    Enter same passphrase again:
  6. 以下のフォルダに秘密鍵(id_rsa)と公開鍵(id_rea.pub)が生成される
    C:\Users\(ユーザー名)\.ssh\
    C:\Documents and Settings\(ユーザー名)\.ssh\
    ※ファイル名を指定した場合は以下のフォルダに生成されます
    C:\Users\(ユーザー名)\
    C:\Documents and Settings\(ユーザー名)\

2.OpenSSHの秘密鍵からPutty形式の秘密鍵を作成

  1. [スタート] ボタンをクリックします。
    OpenSSH_PuttyPrivateKeyCreate001.png
  2. [すべてのプログラム] をクリックします。
    OpenSSH_PuttyPrivateKeyCreate002.png
  3. [TortoiseGit] をクリックします。
    OpenSSH_PuttyPrivateKeyCreate003.png
  4. [Puttygen] をクリックします。
    OpenSSH_PuttyPrivateKeyCreate004.png
  5. [File] メニューの [Load private key] をクリックします。
    OpenSSH_PuttyPrivateKeyCreate005.png
  6. [ファイルの種類] コンボ ボックスをクリックします。
    OpenSSH_PuttyPrivateKeyCreate006.png
  7. [ファイルの種類] コンボ ボックスリストの [All Files (*.*)] をクリックします。
    OpenSSH_PuttyPrivateKeyCreate007.png
  8. OpenSSHの秘密鍵のファイル(拡張子無し)を選択します。
    OpenSSH_PuttyPrivateKeyCreate008.png
  9. [開く] ボタンをクリックします。
    OpenSSH_PuttyPrivateKeyCreate009.png
  10. OpenSSHの鍵を作成した際に設定したパスワードを入力します。
    OpenSSH_PuttyPrivateKeyCreate010.png
  11. [OK] ボタンをクリックします。
    OpenSSH_PuttyPrivateKeyCreate011.png
  12. メッセージ ボックスで、 [OK] ボタンをクリックします。
    OpenSSH_PuttyPrivateKeyCreate012.png
  13. [Save private key] ボタンをクリックします。
    OpenSSH_PuttyPrivateKeyCreate013.png
  14. [ファイル名] コンボ ボックスリストの [ファイル名] ボックスに 「(任意のファイル名).ppk] と入力します。
    OpenSSH_PuttyPrivateKeyCreate014.png
  15. [保存] ボタンをクリックします。
    OpenSSH_PuttyPrivateKeyCreate015.png
  16. Putty形式の秘密鍵(*.ppk)が作成されます
    この鍵はTortoiseGitによるリポジトリのクローン時に使います

Bitbucketのリポジトリを使う

まずは、BitbucketでGitの「リモートリポジトリ」を作成します

  1. Bitbucketにログインします
    https://bitbucket.org/
  2. [Repositories] をクリックします。
    BitbucketCreateRepository001.png
  3. [Create repository] をクリックします。
    BitbucketCreateRepository002.png
  4. [Name] に任意の名前(プロジェクト名等)を入力します。
    ※例では「hogehogerepo」と入力しています
    BitbucketCreateRepository003.png
  5. [Access Lever] の [This is a private repository] にチェックを付けます。
    ※チェックを付けた場合は周りからこのリポジトリの内容は見えなくなります
    ※オープンソース等で、誰からでもリポジトリの内容を見えるようにしたいならチェックを外します
    BitbucketCreateRepository004.png
  6. [Repository Type] に [Git] を選択します。
    BitbucketCreateRepository005.png
  7. [Create repository] ボタンをクリックします。
    BitbucketCreateRepository006.png
  8. 右の歯車アイコンをクリックします。

    #ref(): File not found: "BitbucketCreateRepository007.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  9. [Deployment keys] をクリックします。

    #ref(): File not found: "BitbucketCreateRepository008.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  10. [Add key] ボタンをクリックします。

    #ref(): File not found: "BitbucketCreateRepository009.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  11. [Label] に任意の名前(ユーザー名等)をクリックします。

    #ref(): File not found: "BitbucketCreateRepository010.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  12. OpenSSHの公開鍵(*.pub)をメモ帳等のテキストエディタで開きます。

    #ref(): File not found: "BitbucketCreateRepository011.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  13. テキストの内容を選択してコピー(Ctrl+C)します。

    #ref(): File not found: "BitbucketCreateRepository012.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  14. [Key] にテキストの内容を貼り付け(Ctrl+V)します。

    #ref(): File not found: "BitbucketCreateRepository013.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  15. [Add key] ボタンをクリックします。

    #ref(): File not found: "BitbucketCreateRepository014.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  16. キーが作成されたかを確認します。

    #ref(): File not found: "BitbucketCreateRepository015.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  17. [Clone] をクリックします。

    #ref(): File not found: "BitbucketCreateRepository016.png" at page "Git/Bitbucketのリモートリポジトリを使う"

  18. 中に書かれたCloneコマンドのオプション内容をコピーします。
    ※頭の「git clone 」は必要ありません
    git clone git@bitbucket.org:username/hogehogerepo.git
    ↓
    git@bitbucket.org:username/hogehogerepo.git

    #ref(): File not found: "BitbucketCreateRepository017.png" at page "Git/Bitbucketのリモートリポジトリを使う"

次にクローンを行い「ローカルリポジトリ&ワークツリー」を作成します

  1. Gitで管理したいソースコードを置くためのフォルダを作成します。
    ここでは例として「D:\hogehogeProject」というフォルダを作成します。
  2. 「hogehogeProject」フォルダを右クリック→[Git Clone]
  1. 公開鍵(id_rea.pub)をリモートリポジトリがある環境に設定する
    ※設定方法はGitホスティングサービスのサイト内のドキュメントか、サーバーの管理者に聞いて下さい