Re: undoing something
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 16, 2009, 19:14 UTC
- Message-ID
- <7veiwxwa9z.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <450196A1AAAE4B42A00A8B27A59278E70A2AEFA4@EXCHANGE.trad.tradestation.com>
"John Dlugosz" <JDlugosz@TradeStation.com> writes:
Show 12 quoted lines
> I made a mistake. Big deal, now that I know that git storage is
> immutable and changes just add to what's already there.
>
> A quick look at
> git reflog show topic
> tells me that {1} is the one I want. So, how do I rewind branch topic
> to point to topic@{1} ?
> I did it by making a tag, and then in gitk pointing to it and picking
> "reset to here" from the context menu.
>
> A while back I was looking for the right/easy way to simply repoint my
> branch to where I wanted. The best answer was to use push.The answer was best only because in your previous question you wanted to ensure fast-forwardness, i.e. "git push . origin/dev:dev" without plus in front to cause it to fail if it is not fast-forward.
If you know you have one unwanted commit you would want to discard at the tip of topic, you do not want fast-foward safety to kick in.
(1) if you are on the topic branch, you can say "git reset --hard HEAD^";
or (2) if you are not, you can obviously check out topic and do the above,
or "git branch -f topic topic^".If the garbage you have at the tip of the topic is not just a single commit, you can replace HEAD^ and topic^ in the above with whatever commit you would want to point the tip at.