GitユーザがBitbucketを普通に使うには。

gitでcommitして、Bitbucketにpush!

前回のエントリの続き。
Mercurialインストールして、Bitbucketにも登録して、Gitのリポジトリを反映させて、pushした皆様、お疲れ様です。


ところで、久しぶりにGitに戻って、ばりばり書いてコミットした、…ら、どうすればいいのでしょうか。









目次

 ・前提条件
 ・git clone
 ・Git→Mercurial変更反映
 ・Bitbucketに2回目のpush!


前提条件

★Bitbucket登録済
Mercurial/hg-gitインストール済
GitユーザだけどBitbucket使いたい! - CROSS HOPEの手順をひととおりやった
★Bitbucketにはじめてpushしたあと、Gitでコミットをした

以下の説明ではGit→Mercurial変換が終了したときのフォルダ構成を想定しています。


git clone

ここまでは、前回と同じです。
Gitで管理しているblueというフォルダはDropboxフォルダの中にありますから、移動してからgit cloneします。

$ cd ~/Dropbox
$ git clone --bare blue Mercurial/blue.git
Cloning into bare repository Mercurial/blue.git...
done.


Git→Mercurial変更反映

Gitでcommitした内容を、Mercurialへ引っ張ってきます。
Gitと共通のコマンドかもしれないです(ほぼローカル運用の人)。


1.まずは前回作成したMercurialリポジトリのフォルダに移動しましょう。

$ cd ~/Dropbox/Mercurial/blue-hg


2.cloneしたgitリポジトリから変更を引っ張って来ます。以下のコマンドを実行してください。

$ hg pull ../blue.git
pulling from ../blue.git
importing Hg objects into Git
Counting objects: 3, done.
Compressing objects: 100% (3/3), done.
Total 3 (delta 0), reused 0 (delta 0)
importing Git objects into Hg
(run 'hg update' to get a working copy)


3.↑の最後のメッセージに従って、引っ張って来た変更点を以下のコマンドで反映させます。

$ hg update
1 files updated, 0 files merged, 0 files removed, 0 files unresolved


pullとupdateを行うことで、自分のリポジトリのチェンジセットが最新になるのだとか。
ちなみにチェンジセットとは、(Mercurialでは)「1つ以上のファイルの変更を、1つの論理的な単位にまとめられたもの」です。


Bitbucketに2回目のpush!

Bitbucketにも変更を渡す、つまりpushする準備ができたようです。


1.もう、以下のコマンドを実行するだけ!
 (都合により省略した箇所があります)

$ hg push bitbucket://youraccount/blue
pushing to bitbucket://youraccount/blue
The authenticity of host 'bitbucket.org' can't be established.
RSA key fingerprint is .
Are you sure you want to continue connecting (yes/no)? yes
remote: Warning: Permanently added 'bitbucket.org, (RSA) to the list of known hosts.
remote: Identity added: /Users/you/.ssh/id_rsa (/Users/you/.ssh/id_rsa)
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: bb/acl: youraccount is allowed. accepted payload.


2.Bitbucketにアクセスしてみましょう。
 [Repositories]→[blue]→[Chengesets]をクリックすると、変更履歴を見ることができます。
 blueというgitリポジトリにcommitした内容が反映されていたら成功です。


 今後この手順をくり返すとなると、スクリプトを書いて省力化すべきでしょうかね。

本当におつかれさまでした!

長かったですねえ…。
GitにMercurial、どちらも運用がんばりましょう!


最後に、参考にしたリンク集を添えさせていただきます。

  • 日本語マニュアル!

http://www.selenic.com/mercurial/wiki/index.cgi/JapaneseTutorial

  • コマンドを調べるならこちらへ。

http://mono.kmc.gr.jp/~mak/hiki/?Mercurial%2FHG%A5%B3%A5%DE%A5%F3%A5%C9%B0%EC%CD%F7

  • 私とは逆のことをしてらっしゃるようです。

hg-gitでbitbucketのMercurialリポジトリをgithubにインポートした - 偏った言語信者の垂れ流し

  • よくある質問はここで。

http://mercurial.selenic.com/wiki/JapaneseFAQ