[git]入門git 1.環境構築からコミットまで
入門git読む。(Travis Swicegoodの方(http://www.amazon.co.jp/%E5%85%A5%E9%96%80git-Travis-Swicegood/dp/427406767X)。入門Gitはもう一種類ある)
Git on MSysをインストール
サイト https://code.google.com/p/msysgit/
1.8.3 https://code.google.com/p/msysgit/downloads/detail?name=Git-1.8.3-preview20130601.exe&can=2&q=
インストール時の設定
Adjusting your path environment
真ん中のRun Git from the Windows Command Promptを選択。
これだとシステム環境変数PATHにgitのパスが追加されるだけっぽい。
インストール後の初期設定
git config --global user.name "Hoge Piyo" git config --global user.email "Hoge@hoge.com"
設定値の確認
git config --list
色分け
diffを見るときとかに便利になるらしい。
git config --global color.ui "auto"
エディタの設定
git config --global core.editor "notepad"
変更の追加
gid add ファイル名 git commit -m "コミットメッセージ"
コミットログ確認
git log
コミットログ出力結果
commit 3f16061062e39851cb48a3c5e3e4824ef37a7dbf Author: Hoge PiyoDate: Fri Sep 13 09:38:34 2013 +0900 add in hello HTML
変更の更新
ファイルに変更を加えたあと、
git status
でmodifiedなファイルが見れる。
出力結果例
# On branch master # Changes not staged for commit: # (use "git add..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: index.html # no changes added to commit (use "git add" and/or "git commit -a")
もし変更がなければ以下のメッセージが出る
# On branch master nothing to commit, working directory clean
変更をコミットするにはgit addするとコミットできるようになる。(ステージする?)
# On branch master # Changes to be committed: # (use "git reset HEAD..." to unstage) # # modified: index.html #
変更したファイルをgit addせずにgit commitすると、git statusした場合と同じメッセージが表示され、コミットできない
以下のように-aを付けると変更したものを再度git addせずにコミットできる。
git commit -a