[[戻る>DoldoWorkz#git]] -[[''Git''>Git]] --[[Git/Windowsで使う(msysgit・TortoiseGit)]] --[[Git/Bitbucketのリモートリポジトリを使う]]&color(red){''✓''}; *目次 [#tffb83e8] #contents *Bitbucketとは [#vd0428ae] -[[Free source code hosting for Git and Mercurial by Bitbucket>https://bitbucket.org/]]~ 「Mercurial」または「Git」のリモートリポジトリを管理できるホスティングサービス~ 無料のアカウントでプライベートリポジトリを無制限に生成する事が出来、同時に5ユーザーまで使用する事が出来ます~ ※別途有料プランもあります~ *秘密鍵・公開鍵を作る [#y13dcff4] Bitbucket との通信を暗号化するために、秘密鍵・公開鍵を作成する必要があります。~ **1.OpenSSHの秘密鍵・公開鍵を作成 [#uc057436] +デスクトップにある[Git Bash]ショートカットをクリック~ +以下のコマンドを実行~ ssh-keygen -t rsa +以下の様にファイル名を聞いてくるのでEnterを押す~ ※表示されているフォルダにid_resという名前で生成される~ Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/(ユーザーID)/.ssh/id_rsa): ※ここで好きなファイル名を入力する事が出来ますが、そうした場合は何故か「.ssh」フォルダが作られません~ +鍵を使うためのパスワードを設定する~ ※ここで設定したパスワードは後で何度も使うのでメモして下さい~ Enter passphrase (empty for no passphrase): +もう一度同じパスワードを入力する~ Enter same passphrase again: +以下のフォルダに秘密鍵(id_rsa)と公開鍵(id_rea.pub)が生成される~ C:\Users\(ユーザー名)\.ssh\ C:\Documents and Settings\(ユーザー名)\.ssh\ ※ファイル名を指定した場合は以下のフォルダに生成されます~ C:\Users\(ユーザー名)\ C:\Documents and Settings\(ユーザー名)\ **2.OpenSSHの秘密鍵からPutty形式の秘密鍵を作成 [#u54ed8ef] +[スタート] ボタンをクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate001.png,,60%)~ +[すべてのプログラム] をクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate002.png,,60%)~ +[TortoiseGit] をクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate003.png,,60%)~ +[Puttygen] をクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate004.png,,60%)~ +[File] メニューの [Load private key] をクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate005.png,,60%)~ +[ファイルの種類] コンボ ボックスをクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate006.png,,60%)~ +[ファイルの種類] コンボ ボックスリストの [All Files (*.*)] をクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate007.png,,60%)~ +OpenSSHの秘密鍵のファイル(拡張子無し)を選択します。~ #ref(./OpenSSH_PuttyPrivateKeyCreate008.png,,60%)~ +[開く] ボタンをクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate009.png,,60%)~ +OpenSSHの鍵を作成した際に設定したパスワードを入力します。~ #ref(./OpenSSH_PuttyPrivateKeyCreate010.png,,60%)~ +[OK] ボタンをクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate011.png,,60%)~ +メッセージ ボックスで、 [OK] ボタンをクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate012.png,,60%)~ +[Save private key] ボタンをクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate013.png,,60%)~ +[ファイル名] コンボ ボックスリストの [ファイル名] ボックスに 「(任意のファイル名).ppk] と入力します。~ #ref(./OpenSSH_PuttyPrivateKeyCreate014.png,,60%)~ +[保存] ボタンをクリックします。~ #ref(./OpenSSH_PuttyPrivateKeyCreate015.png,,60%)~ +Putty形式の秘密鍵(*.ppk)が作成されます~ この鍵はTortoiseGitによるリポジトリのクローン時に使います~ *Bitbucketのリポジトリを使う [#ldf33b59] まずは、BitbucketでGitの「リモートリポジトリ」を作成します~ +Bitbucketにログインします~ https://bitbucket.org/ +[Repositories] をクリックします。~ #ref(./BitbucketCreateRepository001.png)~ +[Create repository] をクリックします。~ #ref(./BitbucketCreateRepository002.png)~ +[Name] に任意の名前(プロジェクト名等)を入力します。~ ※例では「hogehogerepo」と入力しています~ #ref(./BitbucketCreateRepository003.png,,60%)~ +[Access Lever] の [This is a private repository] にチェックを付けます。~ ※チェックを付けた場合は周りからこのリポジトリの内容は見えなくなります~ ※オープンソース等で、誰からでもリポジトリの内容を見えるようにしたいならチェックを外します~ #ref(./BitbucketCreateRepository004.png,,60%)~ +[Repository Type] に [Git] を選択します。~ #ref(./BitbucketCreateRepository005.png,,60%)~ +[Create repository] ボタンをクリックします。~ #ref(./BitbucketCreateRepository006.png,,60%)~ +右の歯車アイコンをクリックします。~ #ref(./BitbucketCreateRepository007.png,,60%)~ +[Deployment keys] をクリックします。~ #ref(./BitbucketCreateRepository008.png,,60%)~ +[Add key] ボタンをクリックします。~ #ref(./BitbucketCreateRepository009.png,,60%)~ +[Label] に任意の名前(ユーザー名等)をクリックします。~ #ref(./BitbucketCreateRepository010.png,,60%)~ +OpenSSHの公開鍵(*.pub)をメモ帳等のテキストエディタで開きます。~ #ref(./BitbucketCreateRepository011.png,,60%)~ +テキストの内容を選択してコピー(Ctrl+C)します。~ #ref(./BitbucketCreateRepository012.png,,60%)~ +[Key] にテキストの内容を貼り付け(Ctrl+V)します。~ #ref(./BitbucketCreateRepository013.png,,60%)~ +[Add key] ボタンをクリックします。~ #ref(./BitbucketCreateRepository014.png,,60%)~ +キーが作成されたかを確認します。~ #ref(./BitbucketCreateRepository015.png,,60%)~ +[Clone] をクリックします。~ #ref(./BitbucketCreateRepository016.png,,60%)~ +中に書かれたCloneコマンドのオプション内容をコピーします。~ ※頭の「git clone 」は必要ありません~ git clone git@bitbucket.org:username/hogehogerepo.git ↓ git@bitbucket.org:username/hogehogerepo.git #ref(./BitbucketCreateRepository017.png,,60%)~ 次にクローンを行い「ローカルリポジトリ&ワークツリー」を作成します~ +Gitで管理したいソースコードを置くためのフォルダを作成します。~ ここでは例として「D:\hogehogeProject」というフォルダを作成します。 +「hogehogeProject」フォルダを右クリック→[Git Clone] +公開鍵(id_rea.pub)をリモートリポジトリがある環境に設定する~ ※設定方法はGitホスティングサービスのサイト内のドキュメントか、サーバーの管理者に聞いて下さい~