Skip to content

Instantly share code, notes, and snippets.

@RensDimmendaal
Last active June 28, 2021 17:41
Show Gist options
  • Save RensDimmendaal/1dcc8da0d3b3476443b5905c8e7a3af4 to your computer and use it in GitHub Desktop.
Save RensDimmendaal/1dcc8da0d3b3476443b5905c8e7a3af4 to your computer and use it in GitHub Desktop.
git update after failed pre-commit

Git update after failed pre-commit

Do your commits fail because of pre-commit?

Do those hooks tend to fix the problems they detect? E.g. python's black and isort?

Are you frustrated by having to find out which items were changed and should be updated? Did you ever accidentally add items because you did a lazy git add . when you shouldn't have?

Well here's the solution:

git add <your-stuff>
git commit # fails because black/isort or something else fixes something
git update-index --again # <-- automatically stage updates in <your-stuff> but nothing else
git commit # passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment