githubの始め方はこちらのブログで分かりやすく説明されているので割愛します。
gitのインストールとgithubリポジトリ(project_hoge)の作成は事前に完了しておいて下さい。
- githubへのssh接続に使う秘密鍵と公開鍵のペアを作成 ※名前は自分で指定してますが、それがすべての始まり
- $ ssh-keygen -t rsa -C "github-hoge"
- Generating public/private rsa key pair.
- Enter file in which to save the key (/home/hoge/.ssh/id_rsa): /home/hoge/.ssh/hoge_rsa
- Enter passphrase (empty for no passphrase):パスフレーズ
- Enter same passphrase again:パスフレーズ
- Your identification has been saved in /home/hoge/.ssh/hoge_rsa.
- Your public key has been saved in /home/hoge/.ssh/hoge_rsa.pub.
- The key fingerprint is:
※公開鍵はgithubに追加してくださいね
- $ git config --global user.name "hoge"
- $ git config --global user.email "hoge@example.com"
- $ git config --global color.ui auto
- $ cat -n .gitconfig
- 1 [user]
- 2 name = hoge
- 3 email = hoge@example.com
- 4 [color]
- 5 ui = auto
- $ mkdir project_hoge
- $ cd project_hoge/
- $ git init
- Initialized empty Git repository in /home/hoge/project_hoge/.git/
- $ git var GIT_COMMITTER_IDENT
- hoge <hoge@example.com> 1292429310 +0900
- $ git var GIT_AUTHOR_IDENT
- hoge <hoge@example.com> 1292429366 +0900
- </hoge@example.com></hoge@example.com>
- $ touch README
- $ git add README
- $ git commit -m 'first commit'
- [master (root-commit) 92e6b51] first commit
- 1 files changed, 256 insertions(+), 0 deletions(-)
- create mode 100644 README
- $ git remote add origin git@github.com:hoge/project_hoge.git
- $ git push origin master
- Permission denied (publickey).
- fatal: The remote end hung up unexpectedly
ここらへん見るとそれらしき事が書いてます。
- $ vi /home/hoge/.ssh/config
- 1 Host github.com
- 2 User git
- 3 Port 22
- 4 Hostname github.com
- 5 IdentityFile ~/.ssh/hoge_rsa
- 6 TCPKeepAlive yes
- 7 IdentitiesOnly yes
- $ chmod 600 .ssh/config
- $ git push origin master
- Enter passphrase for key '/home/hoge/.ssh/hoge_rsa':
- Counting objects: 3, done.
- Compressing objects: 100% (2/2), done.
- Writing objects: 100% (3/3), 4.57 KiB, done.
- Total 3 (delta 0), reused 0 (delta 0)
- To git@github.com:hoge/project_hoge.git
- * [new branch] master -> master
以上、メモでしたー。
今日はクラウド勉強会に参加していましたが、とても勉強になりました。
おそらく年内は最後かもですが、勉強会はとても刺激になるので来年も積極的に参加したいですね。