On 04/03/2022 06:25 PM, Philip Oakley wrote:
> That sounds right. The problem I saw (I was reviewing this earlier) was 
> working out my mental model for 'overlay' vs ' no-overlay'.
>
> I think I mapped 'overlay' to 'paint over', so as you checkout a particular 
> commit git will overpaint the relevant parts that the new commit has, but 
> would leave the parts that have apparently 'gone away' unpainted rather than 
> removed.
>
> The no-overlay is like the swapping of drapes and curtains - all the old ones 
> go, and the new ones are put up (unless of of course they are an unchanged 
> drape/curtain/tapestry).
>
> What git won't do is overwrite or remove anything that wasn't formally 
> present in the previous commit as that would be destroying user data like an 
> over enthusiastic house cleaner.
>
> So you need to clean the house to airBnB  status before you change the decor 
> for the next guests.
>
> Hope that pushed the mental model/analogies/metaphors far enough along ;-)
>
> P.
>
> Mentally I had to swap/invert the overlay statements in the restore man page 
> to grasp what it did, rather than what it didn't do.
>
>
> On Sunday, April 3, 2022 at 10:57:04 PM UTC+1 H wrote:
>
>     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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/git-users/e1ca8f9d-1496-4ea3-b9a6-1b3bf937fbb1n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/git-users/e1ca8f9d-1496-4ea3-b9a6-1b3bf937fbb1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

That sounds like a useful metaphor! Thank you for confirming.

-- 
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/fd32b9cd-675e-521e-e219-35beb62d707d%40meddatainc.com.

Reply via email to