From: Oleg Broytman Date: Thu, 25 Jun 2015 18:17:50 +0000 (+0300) Subject: Describe git checkout X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=ab8f276ae1a7c24ba145764144be8f87870282ac;p=git-wiki.git Describe git checkout --- diff --git a/pep-git.txt b/pep-git.txt index 53e30d6..4cbedf6 100644 --- a/pep-git.txt +++ b/pep-git.txt @@ -381,7 +381,20 @@ or shared repository. Undo ==== -TODO: describe undo strategies: git reset, git revert, git checkout, +Whatever you do, don't panic. Almost anything in git can be undone. +``git checkout``, for example, can be used to restore the content of +file(s) to that one of a commit. Like this:: + + git checkout HEAD~ README + +The commands restores the contente of README file to the last but one +commit in the current branch. By default a commit ID is simple HEAD; +i.e. ``git checkout README`` restores README to the latest commit. + +(Do not use ``git checkout`` to view a content of a file in a commit, +use ``git cat-file -p``; e.g. ``git cat-file -p HEAD~:path/to/README``). + +TODO: describe undo strategies: git reset, git revert, git reflog. "Commit early, commit often". How to undo a merge