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

Current directory is not a git directory! #500

Closed
MatteoGioioso opened this issue Jun 9, 2019 · 8 comments
Closed

Current directory is not a git directory! #500

MatteoGioioso opened this issue Jun 9, 2019 · 8 comments

Comments

@MatteoGioioso
Copy link

MatteoGioioso commented Jun 9, 2019

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

@NFhbar
Copy link

NFhbar commented Jun 10, 2019

Also, experiencing this error on git commit -m "message":

husky > pre-commit (node v12.4.0)

> frontend@0.1.0-beta lint-staged /Users/n/Desktop/n/g/client
> lint-staged

Current directory is not a git directory!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0-beta lint-staged: `lint-staged`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@0.1.0-beta lint-staged script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/n/.npm/_logs/2019-06-10T01_34_51_726Z-debug.log
husky > pre-commit hook failed (add --no-verify to bypass)

dir structure:

root/
  .git
  client/
        package.json <-- `husky`
  server/
        package,json

Running git commit from root directory.

client/package.json:

{
  "name": "client",
  "version": "0.1.0-beta",
  "private": true,
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
    "lint-staged": "lint-staged",
    "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,scss,less}\"",
    "eslint": "eslint --ext .js,jsx src",
    "tslint": "tslint \"src/**/*.{ts,tsx}\"",
    "stylelint": "stylelint \"src/**/*.{scss,less}\""
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run lint-staged"
    }
  },
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx,scss,less}": [
      "prettier --write",
      "git add"
    ],
    "src/**/*.{js,jsx}": [
      "eslint"
    ],
    "src/**/*.{scss,less}": [
      "stylelint"
    ]
  },
  "dependencies": {
    "@rowno/sparkline": "^3.0.1",
    "antd": "^3.13.2",
    "axios": "^0.18.0",
    "bootstrap-css-only": "^4.2.1",
    "chart.js": "^2.7.3",
    "chartist": "^0.11.0",
    "chartist-plugin-tooltips-updated": "^0.0.20",
    "classnames": "^2.2.6",
    "connected-react-router": "^6.3.1",
    "d3-dsv": "^1.1.1",
    "d3-format": "^1.3.2",
    "d3-time-format": "^2.1.3",
    "drizzle": "^1.4.0",
    "enquire-js": "^0.2.1",
    "history": "^4.7.2",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "nprogress": "^0.2.0",
    "peity-react": "^0.0.7",
    "prop-types": "^15.7.1",
    "qrcode.react": "^0.9.3",
    "qs": "^6.6.0",
    "rc-drawer": "^1.7.7",
    "react": "^16.8.1",
    "react-c3js": "^0.1.20",
    "react-chartist": "^0.13.3",
    "react-chartjs-2": "^2.7.4",
    "react-custom-scrollbars": "^4.2.1",
    "react-dom": "^16.8.1",
    "react-draft-wysiwyg": "^1.13.1",
    "react-helmet": "^5.2.0",
    "react-intl": "^2.8.0",
    "react-loadable": "^5.5.0",
    "react-redux": "^6.0.0",
    "react-redux-spinner": "^2.0.0",
    "react-router": "^4.3",
    "react-router-dom": "^4.3.1",
    "react-router-redux": "^4.0.8",
    "react-scripts": "2.1.5",
    "react-stockcharts": "^0.7.8",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-saga": "^1.0.1",
    "redux-thunk": "^2.3.0",
    "store": "^2.0.12",
    "web3": "^1.0.0-beta.55"
  },
  "devDependencies": {
    "@babel/plugin-proposal-decorators": "^7.3.0",
    "babel-plugin-import": "^1.11.0",
    "customize-cra": "^0.2.11",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^4.0.0",
    "husky": "^1.3.1",
    "less": "^3.9.0",
    "less-loader": "^4.1.0",
    "lint-staged": "^8.1.3",
    "node-sass": "^4.11.0",
    "react-app-rewired": "^2.1.0",
    "stylelint": "^9.10.1",
    "stylelint-config-prettier": "^4.0.0",
    "stylelint-config-standard": "^18.2.0"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

Note: Never experienced this error before and I have used Husky a bunch before; it just pop randomly.

@abrcdf1023
Copy link

abrcdf1023 commented Jun 10, 2019

Update to latest git version can resolve this issue.

@NFhbar
Copy link

NFhbar commented Jun 11, 2019

Problem persists:

$ git version 2.22.0
$ which git
> /usr/local/bin/git

@AlfredMou
Copy link

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

@AlfredMou
Copy link

Associate issue lint-staged/lint-staged#627

@NFhbar
Copy link

NFhbar commented Jun 11, 2019

@AlfredMou That solved the issue, thanks!

@dmsierra11
Copy link

@AlfredMou thanks! That fixed the issue. For future readers, this is an issue with version 8.2.0, so check your package.json for the lint-staged version to be 8.1.7 and not ^8.1.7 since the later one will install 8.2.0, that is the latest minor version.

@MatteoGioioso
Copy link
Author

Ok, that fixed it for me as well, but I had to update my git version as well. Thanks for the help @AlfredMou

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

5 participants