Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour in git worktree setup #1555

Open
1 task done
svartkanin opened this issue Jan 31, 2025 · 0 comments
Open
1 task done

Strange behaviour in git worktree setup #1555

svartkanin opened this issue Jan 31, 2025 · 0 comments

Comments

@svartkanin
Copy link

Troubleshoot

Context
When using git worktrees the pre-commit hook has some strange behaviours. I have a pre-commit hook that may create a new file based on yarn build output but it can also be reproduced with the following snipplet in the .husky/pre-commit file in a git worktree setup.

cd subfolder
touch test.txt
echo "1234" > test.txt
git add test.txt

When running a commit git commit -am "test" the hook will suddenly create a file test.txt in the root directory and in the subfolder as well. Also the test.txt in the root is added to the commit but then deleted which results in the following status right after running the git commit command

git status
On branch husky-wt-poc

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	deleted:    ../test.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	test.txt

no changes added to commit (use "git add" and/or "git commit -a")

Expected behaviour

The expectations with a git add test.txt in the pre-commit would be that the file created in subfolder/test.txt is added and that no test.txt is created in the root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant