Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i make Visual Studio Code save changes in files before commit?

I have often made a commit, and then noticed that one of the files i was working on wasn't saved, and therefore were left out of the commit.

I have my current project set up with Husky, and have automated things like testing / linting before commit or push.

Here is the current Husky setup, just to give an idea of where a script could fit in.

 "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged && ng lint",
      "pre-push": "ng test --browsers ChromeHeadless --watch=false && testcafe -c 4 chrome:headless test"
    }
  }

Is there any way to make visual studio or Husky save all open files pre-commit?

like image 796
Bille Avatar asked Sep 05 '25 18:09

Bille


1 Answers

@Will Taylor's answer inspired me to do some searching. I found the "files.autoSave": "onFocusChange" setting in VSCode, and it solved my problem to a satisfactory degree. Because the file is loosing focus when I write in the terminal, it is saved befor I commit.

like image 182
Bille Avatar answered Sep 08 '25 21:09

Bille