Not a git repository
Im trying to use husky where I have this kind of directory setup:
--> Project
--> .git
--> SubProject
--> package.json (husky installed)
--> SubProject2
--> package.json (husky installed)
and I get the error
husky > npm run -s precommit (node v8.1.4)
gitError: fatal: Not a git repository: '.git'
Is there a way to tell husky where to look for git ?
You have to add a property gitDir to lint-staged.
"lint-staged": {
"gitDir": "../",
"linters": {
"*.{js,json,jsx}": [
"prettier --single-quote --no-semi --write",
"git add"
]
}
}
https://github.com/okonet/lint-staged#working-from-a-subdirectory https://github.com/okonet/lint-staged/issues/170
This does not work, if you want to use husky without lint-staged
Hey, i'm trying to use Husky without lint staged as well, is there a way to add "gitDir : "../" option to package.json?
https://stackoverflow.com/a/11915540/436540
git --git-dir ../../.git --work-tree ../.. add path/to/my-file.json
It seems the 'gitDir' option has been removed since v3.1 . So, the way to config 'gitDir' doesn't work any more. I solved this problem with just one command in the project root directory: npm install husky -D. You can try it.