git checkout delete directory
I was wondering how i can recover all the files in a directory at once whit git checkout?
You can use the path to the directory to add or remove all files in it at once, like
git add /path/to/dir/
But when i do
git checkout /path/to/dir/
i get something like this
error: pathspec '/path/to/dir/' did not match any fil开发者_如何学Ce(s) known to git.
So i have to manually add every file, is there an easier way?
I think you need to determine the branch
git checkout master
or git checkout <treeish> -- /path/to/dir
More info: http://gitready.com/intermediate/2009/03/18/restoring-a-directory-from-history.html`
Apparently you can do it: watch here for an example. The command
git checkout <treeish> -- /path/to/dir
should be working. In your case you don't specify a branch and it should revert the state of the directory to the last commit.
Maybe you have forgotten --
after the git checkout command.
(I did not even know that it could be used without --
when not dealing with branches.)
精彩评论