2009-07-10
githubに初めてリポジトリを作成する際のチュートリアル
SSH公開鍵を作成する
使用しているパソコンにsshの公開鍵が無い場合は、新たに作成します。
rsaまたはdsaの鍵ペアを既に持っている場合は、このステップは省略します。
cd ~/.ssh ssh-keygen Generating public/private rsa key pair.   Enter file in which to save the key (/Users/username/.ssh/id_rsa): # press enter here   Enter passphrase (empty for no passphrase): # type in your passphrase here   Enter same passphrase again: # type your passphrase again   Your identification has been saved in /Users/username/.ssh/id_rsa.   Your public key has been saved in /Users/username/.ssh/id_rsa.pub.   The key fingerprint is:   30:93:77:c6:97:af:61:82:dc:ea:9b:6b:67:d4:1b:61 user@host  
公開鍵(ここではid_rsa.pubという名前のファイルとします)の内容を以下のようにしてクリップボードにコピーします。
cat id_rsa.pub | pbcopy
githubのアカウントのページを開き、「SSH Public Keys」の項目以下の「add another public key」をクリックし、コピーしてある公開鍵の内容をペーストします。
githubにリポジトリを作成する
http://github.com/repositories/newのページを開き、新しいリポジトリを作成します。
project name、description、homepage urlを必要に応じて記入し、Create Repositoryをクリックして新規リポジトリを作成します。
例
project name: sample
description: my sample repository
homepage url: http://d.hatena.ne.jp/femoco
リポジトリの作成が完了すると、githubが次の作業を指示してくれます。
以下のように表示されました。
Global setup:
Download and install Git
git config --global user.name "FeMoCo"
git config --global user.email email@address.hoge
Next steps:
mkdir sample
cd sample
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:femoco/sample.git
git push origin master
この指示に従い、リポジトリに載せるためのディレクトリを作成していきます。
ここでは、~/code/sampleというディレクトリ以下にファイルを置いていることにします。
cd ~/code mkdir sample cd sample git init touch README git add README git commit -m "first commit" git remote add github git@github.com:femoco/sample.git git push github master ここで公開鍵に対するパスフレーズを訊かれるので、設定したパスフレーズを入力します。
これで、作成したリポジトリにREADMEのみがpushされました。
githubをリモートリポジトリとして設定する
cd ~/code/sample emacs .git/config
作成したconfigファイルを以下のように編集します。
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true [remote "github"] url = git@github.com:femoco/sample.git fetch = +refs/heads/*:refs/remotes/origin/* push = refs/heads/master:refs/heads/master
githubにpushする
sampleディレクトリに何か新しいファイルを作成して、githubにpushしてみます。
cd ~/code/sample emacs sample.txt
sample.txtを以下のように編集してみます。
This is a sample text for github tutorial.
commitし、以下のようにpushします。
git push github master
以上で、githubにpushすることが出来ました。
- 36 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cts=1330672341832&sqi=2&ved=0CCkQFjAA&url=http://d.hatena.ne.jp/femoco/20090710/1247190951&ei=z3JQT8j8G6v2mAXJvPigCg&usg=AFQjCNF1i0nC6Jer0kj7czRLrKu9SesO7w&sig2=2Fnhu1BIQPOWVZgvq
- 32 http://www.google.co.jp/search?q=nifty_scaffold&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:ja:unofficial&client=firefox-a
- 19 http://www.google.co.jp/search?q=nifty_scaffold&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rlz=1R1GGGL_ja&client=firefox-a
- 13 http://www.google.co.jp/search?sourceid=chrome&ie=UTF-8&q=nifty_layout
- 13 http://www.google.co.jp/url?sa=t&rct=j&q=rails fixtures csv&source=web&cd=2&ved=0CCYQFjAB&url=http://d.hatena.ne.jp/femoco/20090710/1247190951&ei=TE6vTt74J6nGmQXn4cSjAg&usg=AFQjCNF1i0nC6Jer0kj7czRLrKu9SesO7w&sig2=WZcKNAvqqTD92HNwuSHB8A
- 11 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&hs=pkK&q=rails+データ投入+csv&btnG=検索&lr=lang_ja
- 10 http://www.google.co.jp/search?client=safari&rls=en&q=nifty_scaffold&ie=UTF-8&oe=UTF-8&redir_esc=&ei=njCRS4rwLY-TkAWJ_5mCDQ
- 10 http://www.google.co.jp/search?gcx=w&sourceid=chrome&ie=UTF-8&q=rake+db:fixtures:load+csv
- 9 http://www.google.co.jp/url?sa=t&source=web&cd=2&ved=0CCAQFjAB&url=http://d.hatena.ne.jp/femoco/20090710/1247190951&rct=j&q=fixture rails csv&ei=e0feTbjoFYr2vwPBioGYBQ&usg=AFQjCNF1i0nC6Jer0kj7czRLrKu9SesO7w
- 8 http://github.com/femoco
