bitbucketがGitに対応して、 しかもMercurialと同様にGitでもprivateなリポジトリを無料で使えるヒャッハー! って気分になっているので、 自分のマシンに入っているgitリポジトリを放り込むテストをしてみた。 基本的にgitだからどうにかなるよね? ね? ってことで。
まず、bitbucketのGitのリポジトリにアクセスするためにsshの公開鍵を登録する。 その前に@ITの記事 Linuxでsshの鍵を作成するには を参考に鍵を作っちゃいましょう。
$ ssh-keygen -t rsa -f bitbucket.org Generating public/private rsa key pair.
で、パスフレーズを聞かれるので二回それを入力する。 それでカレントディレクトリに 「bitbucket.org」という秘密鍵と「bitbucket.org.pub」という公開鍵が作られます。 今回はこいつを使うことにします。
ということで今回作った公開鍵をbitbucketに登録する。
- bitbucketのホームからAccountをクリックしてアカウント設定画面に移動
- 下にスクロールしていったら「SSH Keys」と書かれているところがあるのでそこを表示。
- [Choose key]というボタンがあるのでそれをクリックしてファイル選択画面を表示して 「bitbucket.org」を選択。 (自分は ~/.ssh が見れなかったのでTerminal.appで「open ~/.ssh」して ファイルをD&Dしてみたらディレクトリを覗けたのでそこから選択しました)
- [Choose key]が[Upload key]というラベルに変わるのでクリックしてアップロード
こいつをbitbucketにアクセスする時に使うことにするので ~/.ssh/config を以下のように編集
Host bitbucket.org User git Port 22 Hostname bitbucket.org IdentityFile ~/.ssh/bitbucket.org TCPKeepAlive yes IdentitiesOnly yes
これでssh周りの準備は完了。多分。
そして、bitbucketに適当なGitリポジトリを作る。 基本的な作り方はbitbucketのhelpのCreating a Repositoryを参照。 一応自分がやったこと書いておく。
- bitbucketのホームにある[+]と表示されているボタンをクリックしてリポジトリ作成ページに移動
- リポジトリの名前(name)に「bitbucket_test」と入力。
- 概要(description)も適当に入力。
- リポジトリのタイプでGitを選択。
- 「Create Repository」をクリックしてリポジトリの作成
そして適当にbitbucket_testというプロジェクトのディレクトリを作成。 いつもRails2をやってるのでなんとなくそれで。
$ rails _2.3.5_ bitbucket_test
create [272/312]
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create db/seeds.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
そしてその中に移動
$ cd bitbucket_test
そしてgitリポジトリとして初期化
$ git init Initialized empty Git repository in /Users/mugijiru/tmp/bitbucket_test/.git/
そして全部addしてcommit
$ git add * $ git ci [master (root-commit) 944f366] とりあえずgitリポジトリ作って全部commit 42 files changed, 8461 insertions(+), 0 deletions(-) create mode 100644 README create mode 100644 Rakefile create mode 100644 app/controllers/application_controller.rb create mode 100644 app/helpers/application_helper.rb create mode 100644 config/boot.rb create mode 100644 config/database.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/new_rails_defaults.rb create mode 100644 config/initializers/session_store.rb create mode 100644 config/locales/en.yml create mode 100644 config/routes.rb create mode 100644 db/seeds.rb create mode 100644 doc/README_FOR_APP create mode 100644 log/development.log create mode 100644 log/production.log create mode 100644 log/server.log create mode 100644 log/test.log create mode 100644 public/404.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/favicon.ico create mode 100644 public/images/rails.png create mode 100644 public/index.html create mode 100644 public/javascripts/application.js create mode 100644 public/javascripts/controls.js create mode 100644 public/javascripts/dragdrop.js create mode 100644 public/javascripts/effects.js create mode 100644 public/javascripts/prototype.js create mode 100644 public/robots.txt create mode 100755 script/about create mode 100755 script/console create mode 100755 script/dbconsole create mode 100755 script/destroy create mode 100755 script/generate create mode 100755 script/performance/benchmarker create mode 100755 script/performance/profiler create mode 100755 script/plugin create mode 100755 script/runner create mode 100755 script/server create mode 100644 test/performance/browsing_test.rb create mode 100644 test/test_helper.rb
そしてbitbucketに作ったリポジトリをoriginとして登録
git remote add origin git@bitbucket.org:mugijiru/bitbucket_test.git
そんでもってpushする。
$ git push origin master (git)-[master]
ここで初めてbitbucketにsshで接続しているので、
The authenticity of host 'bitbucket.org (207.223.240.181)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)?
とか聞かれるのでyesって答える。 意味は確か、接続したことないhostだけどやっちゃってええのんか?って感じです。よね?
そしたら
Warning: Permanently added 'bitbucket.org,207.223.240.181' (RSA) to the list of known hosts. Counting objects: 62, done. Delta compression using up to 2 threads. Compressing objects: 100% (55/55), done. Writing objects: 100% (62/62), 79.26 KiB, done. Total 62 (delta 10), reused 0 (delta 0) remote: bb/acl: mugijiru is allowed. accepted payload. To git@bitbucket.org:mugijiru/bitbucket_test.git * [new branch] master -> master
のように表示されてpushが完了っと。 あとで本当にやりたかった方もやろう、うん。

