Reputation: 8762
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 file(s) known to git.
So i have to manually add every file, is there an easier way?
Upvotes: 1
Views: 2714
Reputation: 3742
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.)
Upvotes: 0
Reputation: 124
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`
Upvotes: 1