diff --git a/README.md b/README.md index 96ddc39..6e1436c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1045 TILs and counting..._ +_1046 TILs and counting..._ --- @@ -277,6 +277,7 @@ _1045 TILs and counting..._ - [Show What Is In A Stash](git/show-what-is-in-a-stash.md) - [Single Key Presses in Interactive Mode](git/single-key-presses-in-interactive-mode.md) - [Skip A Bad Commit When Bisecting](git/skip-a-bad-commit-when-bisecting.md) +- [Skip Pre-Commit Hooks](git/skip-pre-commit-hooks.md) - [Staging Changes Within Vim](git/staging-changes-within-vim.md) - [Staging Stashes Interactively](git/staging-stashes-interactively.md) - [Stash Everything](git/stash-everything.md) diff --git a/git/skip-pre-commit-hooks.md b/git/skip-pre-commit-hooks.md new file mode 100644 index 0000000..6ff8c64 --- /dev/null +++ b/git/skip-pre-commit-hooks.md @@ -0,0 +1,30 @@ +# Skip Pre-Commit Hooks + +Projects can choose to adopt pre-commit hooks as part of their contribution +workflow. These hooks can help enforce project standards like ensuring a set of +changes are formatted and linting properly. These can be set up with a tool +like [husky](https://github.com/typicode/husky) or with a custom script. + +As you're working on a feature branch, you can and should make frequent +checkpoint commits like a climber puts +[pitons](https://en.wikipedia.org/wiki/Piton#:~:text=In%20climbing%2C%20a%20piton%20(%2F,assist%20progress%20in%20aid%20climbing.) +into the rock face. These are anchor points that reduce the risk of losing +work. They make it easier and safer to return to a point in time when your code +was in a "good" state. + +If your checkpoint commit isn't conforming to all the pre-commit hook checks, +you can choose to skip the checks and commit anyway. To do this, tack on the +`--no-verify` flag. + +```bash +$ git commit --no-verify +``` + +With this checkpoint in place, you can either plunge forward with the feature +or you can even go fix the pre-commit violations and combine them into +(`--amend`) that checkpoint commit. + +Don't abuse this. You still want the overall work to conform to project +guidelines. Use the process that works best for you as you get there. + +See `man git-commit` for more details.