Re: Revert a single commit in a single file
- From
Michael J Gruber <git@drmicha.warpmail.net>
- Date
- Feb 25, 2011, 13:05 UTC
- Message-ID
- <4D67A92D.2000300@drmicha.warpmail.net>
- In-Reply-To
- <AANLkTimqszvGjVeJHKLPWicDugeOuqbgO1+wy5BO-AE0@mail.gmail.com>
Dario Rodriguez venit, vidit, dixit 25.02.2011 13:48:
> The most sensible way to do this seems to be:
To do what? I you hadn't top posted we would know what "this" referred to.
> git checkout HEAD~2 file.c > > And your index will show file.c modified, as it will have it's content > reverted 2 commits.
It will have its content reset to what it was in HEAD~2. This is very different from reverting the change made in HEAD~2:
> The behavior of 'revert' is to revert commits, not files, so it's not > expected to work if you say 'git revert <commit> <path>'
It makes perfect sense, it's just not implemented.
Note that you can also
git show <commit> -- <path> | git apply -R
to achieve a partial revert. That might be the easiest route to take.
Michael
[Cutting the bottom copy - what is it good for there?]