From ab8f276ae1a7c24ba145764144be8f87870282ac Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 25 Jun 2015 21:17:50 +0300 Subject: [PATCH] Describe git checkout --- pep-git.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 -- 2.39.5