GitHubリポジトリ作成
GitHub · Build software better, together.
環境
Mac OS X 10.6
Gitインストール
Git - Downloadsから。Mac OSX のリンクからたどって最新版をダウンロード。
2011/04/18時点だと git-1.7.4.4-x86_64-leopard.dmg が最新。
ダウンロードしたdmgを展開、pkgを実行してインストール。
公開鍵作成
$ cd ~/.ssh/ $ ssh-keygen -t rsa -C "your@email.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/hogehoge/.ssh/id_rsa): <このままEnter> Enter passphrase (empty for no passphrase): <パスフレーズを入力> Enter same passphrase again: <もう一度同じパスフレーズを入力> Your identification has been saved in /Users/hogehoge/.ssh/id_rsa. Your public key has been saved in /Users/hogehoge/.ssh/id_rsa.pub. The key fingerprint is: 〜〜〜省略〜〜〜 The key's randomart image is: +--[ RSA 2048]----+ | .+ | 〜〜〜省略〜〜〜 | | +-----------------+
確認
$ ls id_rsa ←秘密鍵 id_rsa.pub ←公開鍵
SSH公開鍵の設定
アカウントの設定 > SSH公開鍵 > 別の公開鍵の追加
作成した「id_rsa.pub」の内容をまるっとコピーして「キー」のところにペースト、キーの追加をクリック。
(タイトルは特に入力しなくてもよい)
テスト
$ ssh git@github.com The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? <yes と入力> Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts. Identity added: /Users/hogehoge/.ssh/id_rsa (/Users/hogehoge/.ssh/id_rsa) PTY allocation request failed on channel 0 Hi yourname! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
名前とE-mailの設定
$ git config --global user.name "yourname" $ git config --global user.email your@email.com
GitHub トークン設定
アカウントの設定 > アカウントの管理
APIトークンをコピーしておく。
$ git config --global github.user "yourname" $ git config --global github.token your_api_token
リポジトリに追加してコミットまで
$ mkdir repos $ cd repos/ $ git init Initialized empty Git repository in /Users/ats-matsumoto/repos/.git/ $ touch README $ git add README $ git commit -m 'first commit' [master (root-commit) b2d21e7] first commit 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README $ git remote add origin git@github.com:atsm/repos.git $ git push -u origin master Counting objects: 3, done. Writing objects: 100% (3/3), 220 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To git@github.com:atsm/repos.git * [new branch] master -> master Branch master set up to track remote branch master from origin.
追加されましたね。
atsm/repos · GitHub