I have seen this line in a script I am using :
git config core.worktree ..
I'm not sure what does git worktree do, but I definitively do not understand why to set it to ..
Any clue ? Thanks
I have seen this line in a script I am using :
git config core.worktree ..
I'm not sure what does git worktree do, but I definitively do not understand why to set it to ..
Any clue ? Thanks
Git has two strategies to separate the place your repository folder is (GIT_DIR
) and the place the files being tracked by that repository are (GIT_WORK_TREE
, aka the main work/working tree).
core.worktree
changes the location of the main worktree. In your case, from the default equivalent of .
to ..
which is the parent directory of the one containing the repository folder. Using relative paths in core.worktree
that are outside of GIT_DIR
is the kind of thing you do alone in your room and not in public.
Why would they do this? To track the same files in multiple repositories; the original dev probably had several repositories in sub folders of that parent folder all using ..
for their core.worktree
config. As the previous answer mentioned, it could be a way to share libraries, but there are better strategies to do this.
Since I brought it up, you can take any git repository and replace the .git
repository folder with a .git
file that contains gitdir: <some path>
to point to a new location that will act as the repository folder. It's important to note that <some path>
contains the repository folder name and thus this is a way to change the repository folder name so it isn't .git
. When doing this, you execute your git commands in the location of the .git
file as it is now masquerading as the repository folder.
The vast majority of git GUIs do not correctly support core.worktree
. Any repository using this configuration option should be handled only via terminal commands.
..
means the parent directory.
I'm not sure if you are asking about the ..
syntax, or why the script is using the parent directory.
And for git config core.worktree
, see https://git-scm.com/docs/git-worktree
You may want to post the script so people could understand why the parent directory is used.
It could be a form of library sharing strategy.
The content of the repo you are configuring is most likely shared by multiple other repos via submodules - but whoever wrote that script want to reference all of them to the same working copy locally (as opposed to every repo having its own local copy).
There are pros and cons...
See: Git: Possible to use same submodule working copy by multiple projects?
© 2022 - 2024 — McMap. All rights reserved.