2008-09-05

Git Quick Start

バージョン管理システム Git にも手を出してみる。Git は Linux のカーネルをバージョン管理するために作られた。大規模なソース・コード管理が出来るとのこと。

主な情報元は下記。

インストール

Ubuntu では git-core を入れる (「git」は Gnu Interactive Tools なので注意)。

$ sudo apt-get install git-core

準備

メアドと名前を登録。

$ git config --global user.name "Masayuki Ataka"
$ git config --global user.email your.email.address@gmail.com

コマンドのヘルプ

コマンド git init のヘルプの出し方。2 通りある。

$ man git-init
$ git help init

後者の方が Subversion 使いにはしっくり来るかな。

Init

レポジトリーの作成。

$ mkdir project.foo
$ cd project.foo
$ git init
Initialized empty Git repository in .git/

ファイルの登録

とりあえず、README だけ登録。

$ touch README
$ git add .
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file: README
#
$ git commit -a -m "Add README file"

git status で、コミット前の情報が分かる。けど、デフォールトの表示は Subversion や Bazaar 使いからすると馴染みにくい。

ログ

$ git log

デフォールトで viewer を使って起動する。

修正してコミット

README に「Hello, World」を追加してコミット。追加前には status を実行。diff で差分を取ってチェックしておきませう。

$ vi README
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   README
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git diff
diff --git a/README b/README
index e69de29..ebb98ea 100644
--- a/README
+++ b/README
@@ -0,0 +1,2 @@
+Hello, World.
+
$ git commit -a -m "Add Hello, World"
Created commit 7c156ae: Add Hello, World
 1 files changed, 2 insertions(+), 0 deletions(-)

今日はここまで。

No comments:

Post a Comment