Notizen Annie git hooks - SuQuoc/ft_transcendence GitHub Wiki

Git hooks are scripts that are executed automatically at specific points in the Git workflow.

  • Pre-commit Hook: The pre-commit hook runs before a commit is made.

  • Pre-push Hook: The pre-push hook runs before code is pushed to a remote repository.

  • Post-merge Hook: The post-merge hook runs after a merge is executed.

  • Commit-msg Hook The commit-msg hook runs after the commit message is entered.


  1. you can skip the hook by using --no-verify

git commit --no-verify -m "Your commit message"

git push --no-verify

  1. since we still want to push code according to our internal guideline, we will then run

git reset --soft HEAD~

  1. make the missing changes and corrections to pass the linter etc. and push to the remote repo

git commit with a new commit message

git push -f

if the changes in 3) are done on another pc, when pulling the changes on the original pc we should do

git fetch origin

git reset --hard origin/branch-name


To setup the hooks we should save bash scripts in the appropriates files in the .git/hooks directory of our repo

.git/hooks/pre-commit or .git/hooks/pre-push or .git/hooks/post-merge or .git/hooks/commit-msg

The hooks should be made executable

chmod +x .git/hooks/pre-commit && chmod +x .git/hooks/pre-push && chmod +x .git/hooks/post-merge && chmod +x .git/hooks/commit-msg