[[FrontPage]] ** 元に戻す系 [#e811f425] - git checkout path/to/file -- (git addする前の)ローカルで変更したファイルを元に戻す。 -- svn revert path/to/file相当。 - git rm --cached path/to/file -- git addで''新規追加''したファイルを、git addする前の状態に戻す。 - git rm -r --cached path/to/dir -- git addで''新規追加''したディレクトリを、git addする前の状態に戻す。 - git reset HEAD path/to/file -- 変更してgit addしたファイルを、git addする前の状態に戻す。 - git checkout f2791447 -- 一時的に特定のリビジョンの状態に戻す。 -- svn up -r 1234 相当。 - git checkout f2791447 -- path/to/file -- 特定のファイルだけを一時的に特定のリビジョンの状態に戻す。 - git revert f2791447 -- 特定のリビジョンに戻すような変更を作ってコミットする。 - git reset --hard f2791447 -- HEADを特定のリビジョンに戻す(それ以後の変更を履歴上も無かったことにする)。 ** diff [#nd4f9e35] - git diff -- HEADとワーキングディレクトリの差分を取る。 - git diff --cached -- HEADとインデックスの差分を取る。 - git diff 2e5a5c -- コミット2e5a5cとワーキングディレクトリの差分を取る。 - git diff 14e676 2165ae -- コミット14e676とコミット2165aeの差分を取る。 ** Github [#c7a5da8d] - Githubでforkした人の変更をマージ -- git pull git://github.com/'''username'''/'''project'''.git master -- git push origin master - Githubでforkした人の変更をcherry-pick -- git remote add '''username''' git://github.com/'''username'''/'''project'''.git -- git fetch '''username''' -- git cherry-pick 2776dcfbf78 - [[リモートブランチを削除:http://github.com/guides/remove-a-remote-branch]] -- git push origin :heads/'''branch''' ** その他 [#m4232f77] - ローカルマシンだけにあったgitリポジトリのマスタをリモートマシンに置く手順 -- remote$ cd /home/gimite/gitroot/myproject -- remote$ git init -- local$ git remote add origin ssh://gimite@myserver.example.com/home/gimite/gitroot/myproject -- local$ git push origin master