From a53267fd271b1dd1ea55c9649c75c7d41cd3c9ca Mon Sep 17 00:00:00 2001 From: "Stuart P. Bentley" Date: Thu, 14 Aug 2014 12:01:43 -0700 Subject: [PATCH] Add "I need to undo my last commit" --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 4f9d249..f11ce75 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,16 @@ For clarity's sake all examples in this document use customized bash prompt in o Note that, as with rebasing (see below), amending **replaces the old commit with a new one**, so you must force push (`-f`) your changes if you have already pushed the pre-amended commit to your remote. Be careful when you do this – *always* make sure you specify a branch! + +## I need to undo my last commit + +To reset Git to the state it was in before you made your last commit (while keeping your staged changes): + +``` +(my-branch*)$ git reset --soft HEAD@{1} + +``` + ## I need to combine commits