On 04/02/2022 03:06 PM, H wrote: > On 08/23/2021 06:47 PM, H wrote: >> On August 23, 2021 1:47:19 PM EDT, H <[email protected]> wrote: >>> On 08/22/2021 07:04 PM, H wrote: >>>> 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 [email protected] >>> <mailto:[email protected]>. >>>>>> 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... >>> I found git 2.18 on RH SCL and installed it. Unfortunately that version >>> also does not implement --no-overlay... It seems it was added in git >>> 2.22. >> I found git 2.24 in another repository (IUS) and have installed it so I >> should now be good to go. > It's been a while since the conversation above, I had to spend time on other > projects but am now back trying to get the --no-overlay option to work, so > far without success... > > I am running git 2.24.4 and experimenting with a web project. I have made one > commit of the master tree, then created a useless file in the directory tree > (iow not committed) and now want to restore the previous commit and having > the useless file deleted when restoring. > > I tried (the commit below is the only commit I have, iow from the master > branch, and I am still on the master branch): > > git checkout --no-overlay cdf55e9f84d6f1e7408f2f1be043860951d71f48 > > which results in: > > fatal: '--[no]-overlay' cannot be used with switching branches > > Since I am new to git, I am sure I have misunderstood something. Is there > some other git command I need to issue prior to the one above or is there > some part missing from the git command I used? > > Thank you in advance. > Doing some more research, my understanding has changed. I think I need to run 'git clean' to delete untracked files in my worktree, 'git checkout --no-overlay' does not remove any untracked files, only files that are tracked but have since been deleted.
Is my understanding correct? -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/d3f30271-320e-1b10-e10a-926e34e327e0%40meddatainc.com.
