]> git.phdru.name Git - git-wiki.git/blobdiff - pep-git.txt
Describe ``git reset``
[git-wiki.git] / pep-git.txt
index d13193422d307f9068e66001c1d433e75995b6b0..7ac3fb895070f6d015925815837b8b35a374ad8f 100644 (file)
@@ -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
+<https://git-scm.com/book/en/Git-Tools-Reset-Demystified>`_ 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 <https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things>`_
+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