git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Thiago Farina <tfransosi@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: reverting changes
Date: Thu, 04 Apr 2013 15:19:17 -0700	[thread overview]
Message-ID: <7v8v4ygcre.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CACnwZYe45poRihJToDY5yrLeY-wc=6HSjZBanjGvtiopbuAAFw@mail.gmail.com> (Thiago Farina's message of "Thu, 4 Apr 2013 19:03:57 -0300")

Thiago Farina <tfransosi@gmail.com> writes:

> When I want to revert a change to a file that is already committed
> what is the best way?
>
> The way I found was:
>
> $ git checkout HEAD /path/to/my/file
> $ git reset HEAD /path/to/my/file
>
> Is this the canonical/best way or there other (easier-faster) ways?

If the issue you are solving is:

  What I committed to path/to/my/file is in good state.  I then
  edited path/to/my/file but it turns out that I do not like what I
  did.  I want the version I committed back (perhaps to start over,
  perhaps to do nothing further).

then you can checkout the path out of the commit, i.e.

	git checkout HEAD path/to/my/file

is the canonical and best way.

But I am not sure if that is what you are asking with "want to
revert a change to a file that is already commited".  It can be
read:

    I started from one state, made changes and have already
    committed them.  These changes were bad ones that I regret, and
    I do not want them.

and if so, "git checkout HEAD path/to/my/file" will happily grab the
state after these bad changes are applied out of the commit.

      reply	other threads:[~2013-04-04 22:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04 22:03 reverting changes Thiago Farina
2013-04-04 22:19 ` Junio C Hamano [this message]

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=7v8v4ygcre.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=tfransosi@gmail.com \
    /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).