From 13296423ae7e079af07cebe7360f3ca3b6f4af61 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 26 Jun 2015 22:51:45 +0300 Subject: [PATCH] Describe ``git reset`` --- pep-git.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pep-git.txt b/pep-git.txt index d131934..7ac3fb8 100644 --- a/pep-git.txt +++ b/pep-git.txt @@ -394,7 +394,24 @@ 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 reflog, git revert. +``git reset`` moves the head of the current branch. The head can be +moved to point to any commit but it's often used to remove a commit or +a few (preferably, non-pushed ones) from the top of the branch - that +is, to move the branch backward in order to undo a few non-pushed +commits. + +``git reset`` has three modes of operation - soft, hard and mixed. +Default is mixed. ProGit `explains +`_ the +difference very clearly. Bare repositories don't have indices or +working trees so in a bare repo only soft reset is possible. + +Mixed mode reset with a path or paths can be used to unstage changes - +that is, to remove changes added with ``git add`` for committing. See +`The Book `_ +for details about unstaging and other undo tricks. + +TODO: describe undo strategies: git reflog, git revert. "Commit early, commit often". How to undo a merge -- 2.39.2