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?
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...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.