Is there a way to detach and attach git worktrees? Basically, I'd like to have the following workflow:
- Create a worktree
- Detach work tree after doing some work (adding commits), the directory should not get deleted
- checkout worktree branch in my main checkout
- do some push/linting/pushing to company server
- reattach worktree, and continue working on existing directory if necessary
To explain my reasoning behind my workflow... I have a bunch of settings which are tied into the path of the of the main checkout repository... this includes linting/pre-commit checks and some other workflows (the setup is complicated, and I am unaware of the details)... what I'd ideally like to do is the following switch back and forth from the git worktree
to the main checkout location of the repo.... similar to how you would switch between branches.
e.g. I do the following
- create worktree branch A in dir A
- do some edits
- "unlock" worktree A
- checkout branch A branch in main checkout directory
- do linting/pre-check operation (these do not edit any file in the branch)
- checkout master branch in main checkout directory
- go back to editing worktree A in dir A