Have a look for the `-f|--force` option and the `--no-overlay` option (https://git-scm.com/docs/git-checkout), along with the `-- <pathspec>` syntax (the `--` is space separated) if it is just a single directory from the commit (treeish) that's required.
There is also the `git reset` command but that can be a blunt instrument.. Hope that helps. On Thursday, August 19, 2021 at 2:10:03 AM UTC+1 H wrote: > I am a newcomer to git but have read some of the documentation and > experimented with commits etc. My question, if I want to restore an entire > directory tree with code from a previous commit in git, how do I do that? > > It seems that "git checkout <commit>" does not delete directories and > files in the directory tree that have been created since the commit which > makes sense. Would I thus need to delete the entire directory tree and then > use "git checkout <commit>" to restore everything present in the git commit > to achieve the desired result? > > Thanks. > > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/04e6b1c8-0f3d-4751-8be8-36c61d82b8cbn%40googlegroups.com.