0

I added and deleted a bunch of files in /webroot/modules/mod_menu and I want to get all my .css files back from my last commit. Unfortunately, I've deleted them and I don't remember their names.

If I try to do

git checkout HEAD^ /webroot/modules/mod_menu/*.css

it fails with a message like

error: pathspec '/webroot/modules/mod_menu/css_5XB5aQOGzDUVxnwtHDXg0AJDjmjZbe2Sh1K2BEkR5cM.css' did not match any file(s) known to git.
error: pathspec '/webroot/modules/mod_menu/css_foYlSNpOa-3y78f5xFwefA_kiFD67qfm6I1kXpro1XI.css' did not match any file(s) known to git.
error: pathspec '/webroot/modules/mod_menu/css_n7aK8s-ciXhQyEYWNOJtISbWxtxQiQvnD-N_xWUtD5A.css' did not match any file(s) known to git.

That makes sense: the files it is trying to checkout are new ones, not the files that were in my previous commit. But if I don't know the names of the files, how do I check them out?

Zoe
  • 27,060
  • 21
  • 118
  • 148
doub1ejack
  • 10,627
  • 20
  • 66
  • 125

1 Answers1

0

The documentation for checkout has this in the SYNOPSIS section

git checkout [-p|--patch] [<tree-ish>] [--] [<paths>…]

Looks like you're missing the -- between <tree-ish> and <paths>. The following should work.

git checkout HEAD^ -- /webroot/modules/mod_menu/*.css

what is that -- ? ...

According to this answer The double-dash is used to separate references, such as master or HEAD from file paths...

Community
  • 1
  • 1
Roman
  • 19,581
  • 6
  • 68
  • 84
  • what is that `--`? sometimes it seems synonymous with `HEAD` and sometimes.. it doesn't. – doub1ejack Oct 03 '12 at 15:13
  • @doub1ejack Updated answer to include -- information. It's never synonymous with `HEAD`. `HEAD` is just the default when the `` argument is omitted. – Roman Oct 03 '12 at 15:49