From 98b2eae49b135f206e0f704604aefa83bea86f15 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 29 Jun 2015 19:26:29 +0300 Subject: [PATCH] Split section "Undo" into subsections --- pep-git.txt | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pep-git.txt b/pep-git.txt index d20b336..081bd76 100644 --- a/pep-git.txt +++ b/pep-git.txt @@ -397,6 +397,10 @@ Undo ==== Whatever you do, don't panic. Almost anything in git can be undone. + +git checkout: restore file's content +------------------------------------ + ``git checkout``, for example, can be used to restore the content of file(s) to that one of a commit. Like this:: @@ -409,6 +413,9 @@ 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``). +git reset: remove (non-pushed) commits +-------------------------------------- + ``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 @@ -421,18 +428,29 @@ Default is mixed. ProGit `explains difference very clearly. Bare repositories don't have indices or working trees so in a bare repo only soft reset is possible. +Unstaging +''''''''' + Mixed mode reset with a path or paths can be used to unstage changes - that is, to remove from index 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". +git reflog: reference log +------------------------- + +git revert: revert a commit +--------------------------- How to undo a merge https://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.html +One thing that cannot be undone +------------------------------- + +"Commit early, commit often". + Merge or rebase? ================ -- 2.39.5