threads / discuss / 19159

reverting a file or files back to repository copy

Subject: reverting a file or files back to repository copy

## tl;dr

3 messages between May 2, 2009 and May 2, 2009.

replies: 2people: 3as markdown or json

Aaron Gray· May 2, 2009, 14:54 UTC · lore

How do I do the eqivalent of an 'svn revert' on a single file, on a directory of files, or on all files ?

I found 'git reset --hard HEAD' but it seems like a hammer to crack open a nut.

Many thanks in advance,
Aaron
Peter Harris· May 2, 2009, 15:25 UTC · re: Aaron Gray · lore

Re: reverting a file or files back to repository copy

On Sat, May 2, 2009 at 10:54 AM, Aaron Gray wrote:
> How do I do the eqivalent of an 'svn revert' on a single file, on a
> directory of files, or on all files ?
git checkout <files>
Peter Harris
Markus Heidelberg· May 2, 2009, 15:33 UTC · re: Peter Harris · lore

Re: reverting a file or files back to repository copy

Peter Harris, 02.05.2009:
Show 5 quoted lines
> On Sat, May 2, 2009 at 10:54 AM, Aaron Gray wrote:
> > How do I do the eqivalent of an 'svn revert' on a single file, on a
> > directory of files, or on all files ?
> 
> git checkout <files>

This will use the state of the files from the index. To revert to the latest commit, i.e. discard all your local changes of particular files, use

    git checkout HEAD -- <files>
Markus

← back to recent threads