git環境構築

ソース管理で有名なgithubを使ってみる。
参考:http://d.hatena.ne.jp/goryugo/20081026/1225007428
参考:http://kishi-r.com/2009/07/31/mac_git/


登録は実際にgithubのページにいって行う。特に問題はない。
登録が完了したらリポジトリも1個つくっておく。(sampleという名前で作成した)
githubhttps://github.com/

次にgitのインストール

$ sudo port install git-core
sudo: port: command not found

portないらしいので、wgetのほうでいれる。(wgetもないのでcurlで)

$ curl http://kernel.org/pub/software/scm/git/git-1.6.0.1.tar.gz > git.tar.gz
$ tar xvfz git.tar.gz
$ cd git-1.6.0.1


$ ./configure
$ sudo make
$ sudo make install


$ which git
/usr/local/bin/git

問題なくはいった。
次にgitにアクセスするための鍵を生成する。

$ cd
$ mkdir .ssh
$ cd .ssh


$ ssh-keygen
$ ssh-add

毎回パスワード聞かれるのいやなので、configファイルの生成も行う。

$ vim config


Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes


生成した公開鍵をgithubのAccount Settingsで【SSH Public Keys】に登録する必要がある。

$ cat id_rsa.pub | pbcopy

(これでクリップボードにコピーされるっていうのを初めて知った。)

Account Settings:https://github.com/accountの左カラムから【SSH Public Keys】を選択して貼付ける。名前は何でも。


これで設定完了。

$ cd
$ mkdir git
$ cd git
$ mkdir sample
$ git init


$ touch hoge
$ git add hoge
$ git commit -m "first commit"


$ git remote add origin git@github.com:tyoshii716/sample.git
$ git push origin master