git

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

参考

このエントリーをはてなブックマークに追加
Share on Facebook

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>