blog/content/post/2009/06/06/2009-06-06-gitのチュートリアル-その3.md

28 KiB
Raw Blame History

title author date wordtwit_post_info categories
gitのチュートリアル その3 kazu634 2009-06-06
O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4645;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}
git

前回の続きです。

ログの閲覧

git logでログの閲覧ができます。git log pretty=shortで一行目のログだけを出力します:

~/working/cgi on simoom634 [502] $: git log
commit 2e8708419483eb222400837a88ae2d0901bea12c
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
Date:   Wed Jun 3 23:05:54 2009 +0900
postメソッドを用いたデータの受け渡しを検証
HTMLのformでpostメソッドを用いるformを作成: form02.html
commit c2b79475b349f7879f4058923b9ac2ff38abb1a5
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
Date:   Wed Jun 3 22:59:28 2009 +0900
HTMLページの作成
作成したcgiと連携するHTMLページの作成: form01.html
commit e16a82a1c055de3b262d38260d543b4f4b02117a
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
Date:   Tue Jun 2 23:24:47 2009 +0900
shebangの追加
このままだと実行権限をつけても意味がなかったので、
shebangを追加した。
commit b92fda43865779320e305449f5a55d2e8458ca6c
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
Date:   Tue Jun 2 23:08:33 2009 +0900
Sample Scriptを入力
サンプルスクリプトの入力を完了。
スクリプトはP84に掲載されている。
commit 89d0eebf35b6977d1c21a3ecb122f312db70477a
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
Date:   Tue Jun 2 22:49:14 2009 +0900
Initial Commit
~/working/cgi on simoom634 [503] $: git log --pretty=short
commit 2e8708419483eb222400837a88ae2d0901bea12c
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
postメソッドを用いたデータの受け渡しを検証
commit c2b79475b349f7879f4058923b9ac2ff38abb1a5
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
HTMLページの作成
commit e16a82a1c055de3b262d38260d543b4f4b02117a
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
shebangの追加
commit b92fda43865779320e305449f5a55d2e8458ca6c
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
Sample Scriptを入力
commit 89d0eebf35b6977d1c21a3ecb122f312db70477a
Author: Kazuhiro MUSASHI <simoom634@yahoo.co.jp>
Initial Commit

共有リポジトリを作成する

共有リポジトリを作成するサーバ上で以下のコマンドを実施する。今回は/pub/repository/cgi.gitにレポジトリを作成する:

kazu634@kazu634-desktop% ll                                                                / [2049]
合計 88
drwxr-xr-x   2 root root  4096 2009-06-06 13:48 bin
drwxr-xr-x   3 root root  4096 2009-05-06 23:48 boot
lrwxrwxrwx   1 root root    11 2009-05-06 23:00 cdrom -> media/cdrom
drwxr-xr-x  16 root root  4300 2009-06-06 13:50 dev
drwxr-xr-x 140 root root 12288 2009-06-06 13:50 etc
drwxr-xr-x   3 root root  4096 2009-05-06 23:10 home
lrwxrwxrwx   1 root root    33 2009-05-06 23:12 initrd.img -> boot/initrd.img-2.6.28-11-generic
drwxr-xr-x  19 root root  4096 2009-05-06 23:45 lib
drwx------   2 root root 16384 2009-05-06 22:59 lost+found
drwxr-xr-x   3 root root  4096 2009-06-06 13:49 media
drwxr-xr-x   2 root root  4096 2009-04-13 18:33 mnt
drwxr-xr-x   3 root root  4096 2009-05-06 23:23 opt
dr-xr-xr-x 127 root root      2009-06-06 22:49 proc
drwxr-xr-x   3 root root  4096 2009-06-06 13:42 pub
drwx------  14 root root  4096 2009-05-06 23:32 root
drwxr-xr-x   2 root root  4096 2009-06-06 13:48 sbin
drwxr-xr-x   2 root root  4096 2009-03-07 01:21 selinux
drwxr-xr-x   2 root root  4096 2009-04-20 22:59 srv
drwxr-xr-x  12 root root      2009-06-06 22:49 sys
drwxrwxrwt   7 root root  4096 2009-06-06 13:50 tmp
drwxr-xr-x  11 root root  4096 2009-04-20 23:00 usr
drwxr-xr-x  18 root root  4096 2009-05-16 14:03 var
lrwxrwxrwx   1 root root    30 2009-05-06 23:12 vmlinuz -> boot/vmlinuz-2.6.28-11-generic
kazu634@kazu634-desktop% sudo chmod 777 pub/                                               / [2050]
kazu634@kazu634-desktop% cd pub/repository                                                 / [2051]
kazu634@kazu634-desktop% cd ..                                               /pub/repository [2052]
kazu634@kazu634-desktop% ll                                                             /pub [2053]
合計 4
drwxr-xr-x 2 root root 4096 2009-06-06 14:16 repository
kazu634@kazu634-desktop% sudo chmod 777 repository/                                     /pub [2054]
kazu634@kazu634-desktop% cd repository/                                                 /pub [2055]
kazu634@kazu634-desktop% ll                                                  /pub/repository [2056]
合計 
kazu634@kazu634-desktop% mkdir -p cgi.git                                    /pub/repository [2057]
kazu634@kazu634-desktop% ll                                                  /pub/repository [2058]
合計 4
drwxr-xr-x 2 kazu634 kazu634 4096 2009-06-06 14:17 cgi.git
kazu634@kazu634-desktop% sudo chmod 777 cgi.git/                             /pub/repository [2059]
kazu634@kazu634-desktop% ll                                                  /pub/repository [2060]
合計 4
drwxrwxrwx 2 kazu634 kazu634 4096 2009-06-06 14:17 cgi.git
kazu634@kazu634-desktop% cd cgi.git/                                         /pub/repository [2061]
kazu634@kazu634-desktop% ll                                          /pub/repository/cgi.git [2062]
合計 
kazu634@kazu634-desktop% git init --bare --shared=true               /pub/repository/cgi.git [2063]
Initialized empty shared Git repository in /pub/repository/cgi.git/
kazu634@kazu634-desktop% ll                                          /pub/repository/cgi.git [2064]
合計 32
-rw-rw-r-- 1 kazu634 kazu634   23 2009-06-06 14:18 HEAD
drwxr-xr-x 2 kazu634 kazu634 4096 2009-06-06 14:18 branches
-rw-rw-r-- 1 kazu634 kazu634  126 2009-06-06 14:18 config
-rw-r--r-- 1 kazu634 kazu634   58 2009-06-06 14:18 description
drwxr-xr-x 2 kazu634 kazu634 4096 2009-06-06 14:18 hooks
drwxr-xr-x 2 kazu634 kazu634 4096 2009-06-06 14:18 info
drwxrwsr-x 4 kazu634 kazu634 4096 2009-06-06 14:18 objects
drwxrwsr-x 4 kazu634 kazu634 4096 2009-06-06 14:18 refs

共有レポジトリに変更を反映させる

作業を行う端末上で以下のコマンドを実行する:

~/working/cgi on simoom634 [547] $: git remote add cgi ssh://kazu634@srv634/pub/repository/cgi.git
~/working/cgi on simoom634 [548] $: git show cgi
fatal: ambiguous argument 'cgi': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
~/working/cgi on simoom634 [549] $: git remote show cgi
*1244266136* remote cgi
~/working/cgi on simoom634 [550] $: pwd
/Users/simoom634/working/cgi
~/working/cgi on simoom634 [551] $: git push cgi master
Counting objects: 15, done.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (15/15), 2.52 KiB, done.
Total 15 (delta 2), reused  (delta )
To ssh://kazu634@srv634/pub/repository/cgi.git
* [new branch]      master -> master

「git」に関連する最近のエントリ