git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* reverting changes
@ 2013-04-04 22:03 Thiago Farina
  2013-04-04 22:19 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Thiago Farina @ 2013-04-04 22:03 UTC (permalink / raw)
  To: Git Mailing List

Hi,

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?

Thanks,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: reverting changes
  2013-04-04 22:03 reverting changes Thiago Farina
@ 2013-04-04 22:19 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2013-04-04 22:19 UTC (permalink / raw)
  To: Thiago Farina; +Cc: Git Mailing List

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-04 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-04 22:03 reverting changes Thiago Farina
2013-04-04 22:19 ` Junio C Hamano

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).