summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d3af621)
raw | patch | inline | side by side (parent: d3af621)
author | Linus Torvalds <torvalds@osdl.org> | |
Sun, 7 Aug 2005 01:01:03 +0000 (18:01 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 7 Aug 2005 03:44:20 +0000 (20:44 -0700) |
This was triggered by a query by Sam Ravnborg, and extends "git reset" to
reset the index and the .git/HEAD pointer to an arbitrarily named point.
For example
git reset HEAD^
will just reset the current HEAD to its own parent - leaving the working
directory untouched, but effectively un-doing the top-most commit. You
might want to do this if you realize after you committed that you made a
mistake that you want to fix up: reset your HEAD back to its previous
state, fix up the working directory and re-do the commit.
If you want to totally un-do the commit (and reset your working directory
to that point too), you'd first use "git reset HEAD^" to reset to the
parent, and then do a "git checkout -f" to reset the working directory
state to that point in time too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
reset the index and the .git/HEAD pointer to an arbitrarily named point.
For example
git reset HEAD^
will just reset the current HEAD to its own parent - leaving the working
directory untouched, but effectively un-doing the top-most commit. You
might want to do this if you realize after you committed that you made a
mistake that you want to fix up: reset your HEAD back to its previous
state, fix up the working directory and re-do the commit.
If you want to totally un-do the commit (and reset your working directory
to that point too), you'd first use "git reset HEAD^" to reset to the
parent, and then do a "git checkout -f" to reset the working directory
state to that point in time too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-reset-script | patch | blob | history |
diff --git a/git-reset-script b/git-reset-script
index 0c02aa6423ec485e19bd7439c926addbb8fd029d..b6476edc30b9e8f7c991ebd9e25b530ec49b8253 100755 (executable)
--- a/git-reset-script
+++ b/git-reset-script
#!/bin/sh
. git-sh-setup-script || die "Not a git archive"
-git-read-tree --reset HEAD
+rev=$(git-rev-parse --revs-only --verify --default HEAD "$@") || exit
+rev=$(git-rev-parse --revs-only --verify $rev^0) || exit
+git-read-tree --reset "$rev" && echo "$rev" > "$GIT_DIR/HEAD"
git-update-cache --refresh
rm -f "$GIT_DIR/MERGE_HEAD"