git version 1.7.3
基本
自分で管理している何かをgitで管理しはじめる。
cd hoge
git init
git add .
git commit -m “first hoge”
削除したファイルなど.gitignore対象外以外を全て含めてadd
git add -A .
リポジトリから持ってくる
git clone git://hogehoge.com/hoge.git
作業ディレクトリで変更したファイルを表示
git status
履歴操作
特定のコミットを取り除きたい時
base → commit 1 → commit 2 の中からbaseにcommit 2だけ適用したソースが欲しい場合
現在、commit2の状態だとして、
git revert [commit 1のid]
(この場合だと、git revert HEAD^ でもよい)
特定のコミットのみマージしたい場合
base → commit 1 → commit 2 の中からbaseにcommit 2だけ適用したソースが欲しい場合
baseまたはbaseからの派生をcheckoutした状態で
git cherry-pick [commit2のid]
(commit2のidは事前に調べておくか、)
git reset –hardしちゃった
間違ってやっちゃった場合、焦らず git reflog
参考
- gitねた – holly’s wiki – livedoor Wiki(ウィキ)
- Git ユーザマニュアル (バージョン 1.5.3 以降用)
- Pro Git – Table of Contents(PDF:Pro Git 日本語版PDF (2009-09-26) – Google ドキュメント)


0 Comments.