githubにリポジトリをbakeしてみる

ぺろんです。

以前githubのアカウントを作成したものの、リポジトリがないっていう無意味な状況(爆。
ちょうどcake2+TwitterBootstrapを試してみてるので、そのソースをgit管理しよっかなと。

リポジトリ作るよ。

  1. アカウントTOPに移動 https://github.com/TheSunnySideup
  2. 「New repository」ボタン押下
  3. リポジトリの情報追加
    • 「Project Name」に任意の名前を追加
    • 「Description」に任意の説明を追加
    • リポジトリのアクセスを「Anyone」に指定

ソースをgit管理するよ。

リポジトリ登録したら、リポジトリに管理するためのソースの定義だね。

$ cd /path/to/project
$ git init
Initialized empty Git repository in /path/to/project/.git/
$ cd .git
$ touch README
$ cd ../
$ git add .
$ git commit -a
first commit

初期コミットした状態まで完了。
と安心して git log 見たら、社内案件用に登録したglobal設定されたgitアカウントがコミットログに!!!
これはイカン!ということで、プロジェクト用のアカウント設定をば。

$ cd /path/to/project
$ git config user.name "TheSunnySideup"
$ git config user.email hogehoge@hoge.com
$ git commit --amend --author="TheSunnySideup "

最後のcommit部分は、
さっき間違えて登録したglobalアカウントによるコミットを、登録し直したプロジェクト用のアカウントに書き換えてます。
ということで、git管理されたソースの準備は完了。
さていよいよgithubに登録だよ!

$ git remote add origin git@github.com:TheSunnySideup/cake2.git
$ git push -u origin master
The authenticity of host 'github.com (*******)' can't be established.
RSA key fingerprint is *******.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,*********' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

ぶー。
githubSSH用のkeyを設定しないといけませんね。

$ cd ~/.ssh
$ mkdir key_backup
$ cp id_rsa* key_backup
$ rm id_rsa*
$ ssh-keygen -t rsa -C "hogehoge@hoge.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):

~/.sshgithub用の公開鍵が作成されたので、githubに登録するのら。

  1. アカウントTOPに移動 https://github.com/TheSunnySideup
  2. ヘッダー部のアカウント名横の「Account Settings」アイコンをクリック
  3. 左部のメニュー一覧から「SSH Keys」をクリック
  4. 「Add SSH Key」を押下
  5. 「Key」フィールドに、先ほど作成したid_rsa.pubの内容をコピーして張りつけ
  6. 「Add Key」押下
  7. 最後に接続確認
    • $ ssh -T git@github.com
    • Identity added: ~/.ssh/id_rsa (~/.ssh/id_rsa)
    • Hi TheSunnySideup! You've successfully authenticated, but GitHub does not provide shell access.

$ git push -u origin master
Counting objects: 1262, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1092/1092), done.
Writing objects: 100% (1262/1262), 1.30 MiB | 2.00 MiB/s, done.
Total 1262 (delta 402), reused 0 (delta 0)
To git@github.com:TheSunnySideup/cake2.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

美味しく出来上がりっと!

格言的な

githubのパーカーが欲しい。(格言じゃないしw