From: Oleg Broytman Date: Fri, 26 Jun 2015 19:51:45 +0000 (+0300) Subject: Describe ``git reset`` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=13296423ae7e079af07cebe7360f3ca3b6f4af61;p=git-wiki.git Describe ``git reset`` --- 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