From: Andreas Ericsson <ae@op5.se>
To: Bahadir Balban <bahadir.balban@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: reverting back both working copy and commits
Date: Wed, 11 Jan 2006 20:28:17 +0100 [thread overview]
Message-ID: <43C55C51.90305@op5.se> (raw)
In-Reply-To: <7ac1e90c0601110832u6fc3a3bcwb7e584445610e53f@mail.gmail.com>
Bahadir Balban wrote:
> Hi,
>
> I made some commits that later on I wanted to cancel. I did:
>
> % git-branch master-2006-get-rid-of-commits
>
> % git-reset --hard [sha1id]
>
> where sha1id is the id of commit I want to revert back to. After this,
> git-log points at the right commit (the one with [sha1id]) as the last
> commit made. However, the working copy is left in the original state,
> i.e with the unwanted changes.. How do I also revert the working
> sources into an earlier state.
>
The branch where you do the reset is the one being reset, so you should
have simply done the reset in the original branch without creating a new
one. If you're nervous you're gonna screw up you can do this;
git checkout <branch-with-unwanted-commit>
git tag anchor
git reset --hard <commit-ish>
If you find you've landed on the wrong commit you can undo the change with
git reset --hard anchor
which will restore the branch to wherever you were prior to the first
reset. Making an anchor tag is useful if you do several resets. You can
use ORIG_HEAD to undo a single reset.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
next prev parent reply other threads:[~2006-01-11 19:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-11 16:32 reverting back both working copy and commits Bahadir Balban
2006-01-11 19:28 ` Andreas Ericsson [this message]
2006-01-11 19:37 ` Junio C Hamano
2006-01-12 10:40 ` Bahadir Balban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43C55C51.90305@op5.se \
--to=ae@op5.se \
--cc=bahadir.balban@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).