gitをCentOS5(Final)にインストールして使ってみる。
CentOS5(Final)にgitをインストールして使ってみる。
インストール
参照したサイト。
http://d.hatena.ne.jp/mrgoofy33/20110206/1296952248
http://www.qualysite.co.jp/tech-blog/?p=3131
http://1000g.5qk.jp/tag/%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/
git.repoの追加
[git] name=Base git repository baseurl=http://www.kernel.org/pub/software/scm/git/RPMS/$basearch enabled=1 gpgcheck=0
これなんだけど、yum updateを実行すると
.... http://www.kernel.org/pub/software/scm/git/RPMS/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found Trying other mirror. Error: Cannot retrieve repository metadata (repomd.xml) for repository: git. Please verify its path and try again ....
というエラーがでる。なので結局git.repoを削除した。
rpmforge.repoの追加
これはすでに追加してあった。
[rpmforge] name = Red Hat Enterprise $releasever - RPMforge.net - dag #baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge enabled = 0 protect = 0 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck = 1
gitのインストール
つまり、rpmforgeの設定だけを行った状態で、以下を実行したところうまくいってしまった。
# yum install git --enablerepo=rpmforge .... Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing for dependencies: git i386 1.7.8.2-2.el5.rf rpmforge 6.7 M perl-Git i386 1.7.8.2-2.el5.rf rpmforge 25 k Transaction Summary ============================================================================= Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 6.8 M Is this ok [y/N]: y Downloading Packages: (1/2): perl-Git-1.7.8.2-2 100% |=========================| 25 kB 00:00 (2/2): git-1.7.8.2-2.el5. 100% |=========================| 6.7 MB 00:13 .... Installing: perl-Git ######################### [1/2] Installing: git ######################### [2/2] Dependency Installed: git.i386 0:1.7.8.2-2.el5.rf perl-Git.i386 0:1.7.8.2-2.el5.rf Complete! # which git /usr/bin/git # git --version git version 1.7.8.2 #
使い方
http://www.ne.jp/asahi/hishidama/home/tech/git/github.html
http://d.hatena.ne.jp/pneumaster/20090615/1245045677
http://rogerdudler.github.com/git-guide/index.ja.html
1. sshの公開鍵を登録
github.comにログインしてaccount settingsのSSH Public Keysからssh公開鍵を登録。
ssh-keygenで作った~/.ssh/id_dsa.pubをコピペするのだが、1行になるようにペーストすること(teratermでは改行しちゃうので注意)。
以下のようにsshでテストしてみる。
$ ssh git@github.com The authenticity of host 'github.com (XXX.XX.YYY.ZZZ)' can't be established. RSA key fingerprint is XX:YY:ZZ:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,XXX.XX.YYY.ZZZ' (RSA) to the list of known hosts. Hi githubのユーザID! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. $
「githubのユーザIDで認証されたが、shellを提供していないので接続終了」とメッセージが出ればOK。
2. githubでリポジトリを作成
ログイン画面のトップにある、「Create A Repository」の絵をクリックし、「Click New Repository」をクリックしてプロジェクト名を入力。他は任意。
登録すると使い方が表示される。
3. ローカルの作業環境の作成
上記で表示された使い方をもとにしてローカルマシンで作業環境を作成する。
githubを初めて使う場合、最初だけ以下を実行。
$ git config --global user.name "githubのユーザID" $ git config --global user.email githubの登録時に指定したメールアドレス
以下から作業環境の作成。
$ mkdir jquery-pagescroll $ cd jquery-pagescroll/ $ git init Initialized empty Git repository in /home/foo/bar/github/jquery-pagescroll/.git/ $ touch README $ git add README $ git commit -m 'first commit' [master (root-commit) 0148510] first commit 1 files changed, 24 insertions(+), 0 deletions(-) create mode 100644 README $ git remote add origin git@github.com:"githubのユーザID"/jquery-pagescroll.git $ git push -u origin master Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 587 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To git@github.com:"githubのユーザID"/jquery-pagescroll.git * [new branch] master -> master Branch master set up to track remote branch master from origin. $
gitの特徴としては、git remote add origin ....にてorigin(gitでは慣例の名前)としてgithubのリポジトリを結び付けてpushする。masterは初期値のブランチ名らしい。
READMEファイルがあるとそれがgithubのリポジトリページで表示される。拡張子により、wiki風だったりかけるらしい。