From 542884da1388261c204ae49e9c3a661093485640 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Sun, 9 Apr 2017 16:20:44 +0800 Subject: [PATCH 1/2] Improve "discard specific unstaged changes" steps --- README.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c4e5ccaf..2e496137 100644 --- a/README.md +++ b/README.md @@ -299,21 +299,11 @@ $ git reset filename When you want to get rid of some, but not all changes in your working copy. -First strategy, stash all good changes, reset working copy, reapply good changes. +Checkout undesired changes, keep good changes. ```sh -$ git stash -p -# Select all of the snippets you want to save -$ git reset --hard -$ git stash pop -``` - -Alternate strategy, stash undesired changes, drop stash. - -```sh -$ git stash -p -# Select all of the snippets you don't want to save -git stash drop +$ git checkout -p +# Answer y to all of the snippets you want to drop ``` ## Branches From 51d78e43c5e2fe0f040992764bdb1d433d18e332 Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Mon, 5 Jun 2017 12:08:56 +0100 Subject: [PATCH 2/2] Adding stashes back in --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 2e496137..b587f1e7 100644 --- a/README.md +++ b/README.md @@ -306,6 +306,23 @@ $ git checkout -p # Answer y to all of the snippets you want to drop ``` +Another strategy involves using `stash`. Stash all the good changes, reset working copy, and reapply good changes. + +```sh +$ git stash -p +# Select all of the snippets you want to save +$ git reset --hard +$ git stash pop +``` + +Alternatively, stash your undesired changes, and then drop stash. + +```sh +$ git stash -p +# Select all of the snippets you don't want to save +$ git stash drop +``` + ## Branches