Skip to content
Snippets Groups Projects
  • Case Nelson's avatar
    8108f0aa
    Add git pre-commit hook to catch `nocommit` lines (#22096) · 8108f0aa
    Case Nelson authored
    Sometimes you’ll make a change to some code and not want to commit it. You probably add a comment to the code and hope you’ll either see the comment in the diff before committing or just remember not to check in the change. If you’ve ever done this you’ve probably also committed something you didn’t mean to commit. I know I have.
    
    Below is a git pre-commit hook that searches for the text `nocommit` and if found rejects the commit. With it you can stick `nocommit` in a comment next to the change you don’t want committed and know that it won’t be committed.
    
    You can maintain a list of personal forbidden words by exporting
    `NOCOMMIT_RE` e.g:
    `export NOCOMMIT_RE="spy|tap>|curse word"`
    Add git pre-commit hook to catch `nocommit` lines (#22096)
    Case Nelson authored
    Sometimes you’ll make a change to some code and not want to commit it. You probably add a comment to the code and hope you’ll either see the comment in the diff before committing or just remember not to check in the change. If you’ve ever done this you’ve probably also committed something you didn’t mean to commit. I know I have.
    
    Below is a git pre-commit hook that searches for the text `nocommit` and if found rejects the commit. With it you can stick `nocommit` in a comment next to the change you don’t want committed and know that it won’t be committed.
    
    You can maintain a list of personal forbidden words by exporting
    `NOCOMMIT_RE` e.g:
    `export NOCOMMIT_RE="spy|tap>|curse word"`
Code owners
Assign users and groups as approvers for specific file changes. Learn more.