はじめに
表題の件について簡単な覚え書きを残しておこう。詳しくはbitbucket Documentation Home - bitbucket - Atlassian Documentation - Confluenceを参照のこと。
Mercurial版
Mercurial + Bitbucket = 最高! - presentで説明されている手順に従えばよい。
- gnupackへのMercurialの導入とユーザー名の登録
- bitbucketでのリポジトリの作成と、その情報の取得
- bitbucketでMercurial 用のリポジトリを作成する
- bitbucketのoverview タブにある"Clone this repository"の次の行(hg clone https://...と以下の画像のように表示されている箇所)をコピーする。
- clone, add, commit, push
- クローンリポジトリを作成したいディレクトリに移動し(cd)、コピーした文字列を貼り付けて実行する(hg clone https://...)
- リポジトリに移動してファイルを作成し、hg add ファイル名 と入力する
- その後、hg commit -m "first commit!" のように、コミットした情報を -m に続けて入力する
- 上記の hg clone https://... の clone を push に変えて入力する、つまり hg push https://... と入力する
Git版
ローカルの既存のgitリポジトリをbitbucketに放り込む方法: 麦汁三昧で説明されている手順に大体従えばよい。
私の環境では(上記のMercurialのような) HTTPS 版のアクセスがうまくいかなかったので*1、ここではSSH版の操作手順を書き残しておく。
- gnupackへのGitの導入
- gnupack の mintty.exe を起動し、apt-cyg install git と入力する
- sshの公開鍵を生成する
Host bitbucket.org User git Port 22 Hostname bitbucket.org IdentityFile ~/.ssh/bitbucket.org TCPKeepAlive yes IdentitiesOnly yes
- clone, add, commit, push
- クローンリポジトリを作成したいディレクトリに移動し(cd)、コピーした文字列を貼り付けて実行する(git clone git@bitbucket.org:...)
- ユーザー名を登録するには git config user.name "ユーザー名"、メールアドレスを登録するには git config user.email "メールアドレス" と入力する。config のオプションについてはPro Git - Pro Git 1.5 使い始める 最初のGitの構成を参照すること。
- ファイルを作成し、git add ファイル名 と入力する
- その後、git commit -m "first commit!" のように、コミットした情報を -m に続けて入力する
- git remote add origin まで入力し、上記のコピーした情報のうち git@bitbucket.org以下(git@bitbucket.org:...)を貼り付ける
- git push origin master と入力する
上記のMercurialの操作手順とは異なり、既存のディレクトリをリポジトリとして登録するには、リポジトリを作成したいディレクトリに移動し、git init と入力すればよい。
*1:"git push origin master"と入力すると一切応答しなくなってしまった。