Current directory is not a git directory!

See original GitHub issue

Every time I try to commit with husky I get this error

husky > pre-commit (node v11.15.0)
Current directory is not a git directory!
husky > pre-commit hook failed (add --no-verify to bypass)

This error is happening only when husky is activated. I have used husky before and I never had this error.

my package.json

{
  "name": "root",
  "private": true,
  "devDependencies": {
    "husky": "^2.4.0",
    "lerna": "^3.14.1",
    "lint-staged": "^8.2.0",
    "prettier": "^1.18.2"
  },
  "scripts": {
    ...
  },
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --write",
      "git add"
    ]
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  }
}

OS: Ubuntu 18.04.2 LTS Node 11.15.0 Git: 2.17.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:8

github_iconTop GitHub Comments

4reactions
abrcdf1023commented, Jun 10, 2019

Update to latest git version can resolve this issue.

3reactions
AlfredMoucommented, Jun 11, 2019

This is bug with lint-staged. you can npm install lint-staged@8.1.7 solve this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error:Current directory is not a git directory! · Issue #627
I have this problem when I installed the new version of lint-staged. I think it may be because my .git is in the...
Read more >
Check if current directory is a Git repository - Stack Overflow
If a git repository exists in the current directory, then git branch and git tag ... git tag : Getting tags of the...
Read more >
Git error - Fatal: Not a git repository and how to fix it | Datree.io
A Git command needs to be run on a specific repository, so this error typically occurs when a Git command is run in...
Read more >
Solving “Fatal: Not A Git Repository” (Or Any Of The Parent ...
This command will show the current state of the repository if the current folder is part of a Git repository.
Read more >
How to Fix the “fatal: not a git repository” Error - ContainIQ
In short, the fatal: not a git repository error indicates that your current working directory isn't tracked by Git. If you find yourself...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found