Currently git worktree is not supported. The following error appears:
Suggested solution
before attempting to read .git as a directory stat it to determine if it is a worktree (where .git is a file containing a path) or not (where it is a directory)
Then add a config such as this one to package.json
"nano-staged": {
"**/*.js": [
"prettier -w"
],
}
Now commit the initial setup, then create a new worktree and attempt to make a commit there
git add -A
git commit -m "Initial setup"
git worktree add ../test-project-dev -b dev-branch # creates new worktree with its own branch
# note that a branch cannot be checked out by multiple worktrees,
# thus a new branch is required
cd ../test-project-dev
yarn # install in the new worktree
touch a-file.js
git add a-file.js
git commit -m "added a file"
You should now get the error as in the current working directory .git is a file describing the location of its location in the .git directory of the main tree. For more information on worktrees see git-worktree
Clear and concise description of the problem
Currently
git worktree
is not supported. The following error appears:Suggested solution
before attempting to read
.git
as a directory stat it to determine if it is a worktree (where .git is a file containing a path) or not (where it is a directory)Alternative
No response
Additional context
To recreate create a new project:
Then add a config such as this one to
package.json
Now commit the initial setup, then create a new worktree and attempt to make a commit there
You should now get the error as in the current working directory
.git
is a file describing the location of its location in the.git
directory of the main tree. For more information on worktrees see git-worktree