threads / discuss / 14945

Help reverting a particular file

Subject: Help reverting a particular file

## tl;dr

3 messages between Aug 11, 2008 and Aug 12, 2008.

replies: 2people: 3as markdown or json

Bryan Richardson· Aug 11, 2008, 23:00 UTC · lore
Hello all,

Can anyone tell me how to revert a particular file using git? I executed a commit, then froze my Rails application to the latest Rails version. This caused my custom config/boot.rb file to be overwritten and I would like to restore it without rolling back to the previous commit (which would roll back the rails freeze). In general I need to know how to do this anyway. :)

Please help!

-- Thanks! Bryan

Eric Raible· Aug 11, 2008, 23:33 UTC · re: Bryan Richardson · lore

Re: Help reverting a particular file

Bryan Richardson <btricha <at> gmail.com> writes:
Show 16 quoted lines
> 
> Hello all,
> 
> Can anyone tell me how to revert a particular file using git?  I
> executed a commit, then froze my Rails application to the latest Rails
> version.  This caused my custom config/boot.rb file to be overwritten
> and I would like to restore it without rolling back to the previous
> commit (which would roll back the rails freeze).  In general I need to
> know how to do this anyway. :)
> 
> Please help!
> 
> --
> Thanks!
> Bryan
> 
See corresponding man page for full details, but briefly:

# Updates index as well git checkout HEAD^ -- config/boot.rb

or

# Output can be redirected git show HEAD^:config/boot.rb

- Eric
Alex Riesen· Aug 12, 2008, 06:15 UTC · re: Eric Raible · lore

Re: Help reverting a particular file

Eric Raible, Tue, Aug 12, 2008 01:33:17 +0200:
Show 15 quoted lines
> Bryan Richardson <btricha <at> gmail.com> writes:
> > 
> > Can anyone tell me how to revert a particular file using git?  I
> > executed a commit, then froze my Rails application to the latest Rails
> > version.  This caused my custom config/boot.rb file to be overwritten
> > and I would like to restore it without rolling back to the previous
> > commit (which would roll back the rails freeze).  In general I need to
> > know how to do this anyway. :)
> > 
> 
> See corresponding man page for full details, but briefly:
> 
> # Updates index as well
> git checkout HEAD^ -- config/boot.rb
> 

That'd revert it to the _previous_ commit, not the current, while he seems to need the recently committed state in his working tree:

  git checkout HEAD -- config/boot.rb

← back to recent threads