On 08/22/2021 04:23 PM, H wrote:
> On 08/19/2021 06:08 AM, Philip Oakley wrote:
>> 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 
>> <mailto: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
>>  
>> <https://groups.google.com/d/msgid/git-users/04e6b1c8-0f3d-4751-8be8-36c61d82b8cbn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> Thank you, it looks like this is what I need!
>
Just tried the --no-overlay option and it seems the version of git supplied by 
my operating system, CentOS 7, version 1.8.3.1, does not (yet) implement 
--no-overlay...

My understanding is that while --force would overwrite files in the directory 
tree but not remove newly added files/directories not in the git archive and 
hence, not clean up as I would like...

-- 
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/839653c3-3d0b-cf36-ba01-098d11e3db6a%40meddatainc.com.

Reply via email to