2

I have git status reporting numerous files deleted from my sandbox:

#   deleted:    prj1/.classpath
#   deleted:    prj1/.project
#   deleted:    prj1/default.properties
#   deleted:    prj2/.classpath
#   deleted:    prj2/default.properties
#   deleted:    prj3/.classpath
#   deleted:    prj3/default.properties
#   deleted:    prj4/.classpath
#   deleted:    prj4/default.properties
#   deleted:    prj5/.classpath
#   deleted:    prj5/default.properties
#   deleted:    prj6/.classpath
#   deleted:    prj6/default.properties
#   deleted:    prj7/.classpath
#   deleted:    prj7/default.properties

Now I want to check them out from the local repository (.git, I don't have a remote repository).

In CVS I used to just do cvs update and it would restore all missing files, in the entire hierarchy.

How do I do the same in Git?

I know about git pull origin master but that only works with a remote repository.

I also know about git checkout -- file but I don't want to type all the file names and their paths. I am looking for something as convenient as cvs update.

How do I do that in git?

Bill The Ape
  • 3,261
  • 25
  • 44

1 Answers1

2

I think what you are looking for is

git reset --hard HEAD

This will revert everything to the last committed state, including files you have deleted.

David Bauer
  • 399
  • 1
  • 7
  • Yes, I just found [it](http://stackoverflow.com/a/5812972/1124861) after much search. There is a difference, though, as `cvs update` will not step over modified files, unlike `git reset --hard HEAD`. Is there a more precise equivalent? Thanks +1. – Bill The Ape Jan 12 '12 at 04:16
  • 4
    Well if you only want to restore deleted files this may work for you `git ls-files -d | xargs git checkout --` – David Bauer Jan 12 '12 at 04:38