How to restore changed file in to git workspace when lint-staged lint error?

42 views Asked by At

I use git add . and git commit -m "test", but there are some error when eslint --fix,How to I can take the changed filed from stash area into workspace?

Thank you for your help

// package.json
{
  "lint-staged": {
    "./src/**/*": ["eslint --fix", "prettier --write"]
  },
  "devDependencies": {
    "@commitlint/cli": "^18.4.3",
    "@commitlint/config-conventional": "^18.4.3",
    "@typescript-eslint/eslint-plugin": "^6.13.1",
    "@typescript-eslint/parser": "^6.13.1",
    "@vitejs/plugin-vue": "^4.5.0",
    "eslint": "^8.54.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.1",
    "husky": "^8.0.3",
    "lint-staged": "^15.1.0",
    "prettier": "^3.1.0",
    "typescript": "^5.2.2",
    "vite": "^5.0.0",
    "vue-tsc": "^1.8.22"
  }
}
# pre-commit
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
1

There are 1 answers

0
Andrei Kulik On

You can use git stash pop command to get stashed changes. You can find more information here: https://git-scm.com/docs/git-stash#_commands