[[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の差分を取る。
- git diff 14e676 2165ae path/to/file
-- コミット14e676とコミット2165aeのpath/to/fileの差分を取る。

** 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 show 2e5a5c:path/to/file

- ローカルマシンだけにあったgitリポジトリのマスタをリモートマシンに置く手順
-- remote$ mkdir /home/gimite/gitroot/myproject
-- remote$ cd /home/gimite/gitroot/myproject
-- remote$ git init --bare
-- local$ git remote add origin ssh://gimite@myserver.example.com/home/gimite/gitroot/myproject
-- local$ git push origin master

- [[リモートリポジトリ(push/pullする先)を確認:http://tobysoft.net/wiki/index.php?git%2F%A5%EA%A5%E2%A1%BC%A5%C8%A5%EA%A5%DD%A5%B8%A5%C8%A5%EAURL%A4%F2%CA%D1%B9%B9%A4%B9%A4%EB%CA%FD%CB%A1]]
-- git config remote.origin.url
- [[リモートリポジトリ(push/pullする先)を変更:http://tobysoft.net/wiki/index.php?git%2F%A5%EA%A5%E2%A1%BC%A5%C8%A5%EA%A5%DD%A5%B8%A5%C8%A5%EAURL%A4%F2%CA%D1%B9%B9%A4%B9%A4%EB%CA%FD%CB%A1]]
-- git config remote.origin.url ssh://gimite@myserver.example.com/home/gimite/gitroot/myproject

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS