Teach "am" and "rebase" to mark the original position with ORIG_HEAD
"merge" and "reset" leave the original point in history in ORIG_HEAD, which makes it easy to go back to where you were before you inflict a major damage to your history and realize that you do not like the result at all. These days with reflog, we technically do not need to use ORIG_HEAD, but it is a handy way nevertheless. This teaches "am" and "rebase" (all forms --- the vanilla one that uses "am" as its backend, "-m" variant that cherry-picks, and "--interactive") to do the same. The original idea and a partial implementation to do this only for "rebase -m" was by Brian Gernhardt; this extends on his idea. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -241,6 +241,7 @@ else
|
|||||||
: >"$dotest/rebasing"
|
: >"$dotest/rebasing"
|
||||||
else
|
else
|
||||||
: >"$dotest/applying"
|
: >"$dotest/applying"
|
||||||
|
git update-ref ORIG_HEAD HEAD
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -549,6 +549,7 @@ EOF
|
|||||||
has_action "$TODO" ||
|
has_action "$TODO" ||
|
||||||
die_abort "Nothing to do"
|
die_abort "Nothing to do"
|
||||||
|
|
||||||
|
git update-ref ORIG_HEAD $HEAD
|
||||||
output git checkout $ONTO && do_rest
|
output git checkout $ONTO && do_rest
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -378,7 +378,7 @@ fi
|
|||||||
echo "First, rewinding head to replay your work on top of it..."
|
echo "First, rewinding head to replay your work on top of it..."
|
||||||
git checkout "$onto^0" >/dev/null 2>&1 ||
|
git checkout "$onto^0" >/dev/null 2>&1 ||
|
||||||
die "could not detach HEAD"
|
die "could not detach HEAD"
|
||||||
# git reset --hard "$onto^0"
|
git update-ref ORIG_HEAD $branch
|
||||||
|
|
||||||
# If the $onto is a proper descendant of the tip of the branch, then
|
# If the $onto is a proper descendant of the tip of the branch, then
|
||||||
# we just fast forwarded.
|
# we just fast forwarded.
|
||||||
|
Reference in New Issue
Block a user