git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Thomas Ferris Nicolaisen <tfnico@gmail.com>, git@vger.kernel.org
Subject: Re: Revert a single commit in a single file
Date: Fri, 25 Feb 2011 13:37:39 +0100	[thread overview]
Message-ID: <4D67A293.2050306@drmicha.warpmail.net> (raw)
In-Reply-To: <AANLkTimLRc4LybUvmD2ZCKfQqEP+vr+2aBnb4n3B+Mb2@mail.gmail.com>

Ævar Arnfjörð Bjarmason venit, vidit, dixit 25.02.2011 12:17:
> On Fri, Feb 25, 2011 at 11:34, Thomas Ferris Nicolaisen
> <tfnico@gmail.com> wrote:
>> I tried asking the same question on the "newbie" list some time ago:
>>
>> http://groups.google.com/group/git-users/browse_thread/thread/d562b4eeac016711
>>
>> Basically, when I go
>>> git revert <commit> <path>
>>
>> .. my expectation was that a new commit would be made reverting the
>> changes from the old commit, but only for specified path/file.
>>
>> Maybe it's a bit of a corner-case, but still would be nice to have
>> once in a while. What do you think?
> 
> It would. What you can do in the meantime is:
> 
>     git revert <commit>

Ævar meant to write "git revert --no-commit <commit>" here. (Or there
wouldn't be anything to reset and add.)

>     git reset
>     git add <path>
>     git commit ...
>     git reset --hard # making sure you didn't have uncommited changes earlier

If you want to revert changes to all files but a few, you can do it the
other way round (revert, checkout HEAD^ -- <path>, commit --amend).

Cheers,
Michael

  reply	other threads:[~2011-02-25 12:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-25 10:34 Revert a single commit in a single file Thomas Ferris Nicolaisen
2011-02-25 11:17 ` Ævar Arnfjörð Bjarmason
2011-02-25 12:37   ` Michael J Gruber [this message]
2011-02-25 12:48     ` Dario Rodriguez
2011-02-25 13:05       ` Michael J Gruber
2011-02-25 14:38         ` Thomas Ferris Nicolaisen
2011-02-25 15:19           ` Dario Rodriguez
2011-02-25 18:53 ` Junio C Hamano
2011-02-25 19:43   ` Ævar Arnfjörð Bjarmason
2011-02-25 19:54     ` Junio C Hamano
2011-02-25 20:05       ` Ævar Arnfjörð Bjarmason
2011-02-25 20:22       ` Jay Soffian
2011-02-26  0:27         ` Dario Rodriguez

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=4D67A293.2050306@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tfnico@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).