There should be a directory .git/hooks/ in your repo root directory (hidden directories need to be displayed first), and create a new file pre-commit in it (the current user needs to have execution permissions). The content is roughly as follows:
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
/usr/local/opt/mysql/bin/mysqldump -uroot -p111111 -S /tmp/mysql-3306.socket dbname --no-data > path/to/dbfile/dbname.sql
git add path/to/dbfile/dbname.sql
The above mysql user, password, and dbname must become your own.
Support @samoay's answer.
But there is a tip, the pre-commit hook is a client-side hook.
You will need to copy this hook file to your co-developers if they need it.
pre-commit git hook
There should be a directory
.git/hooks/
in your repo root directory (hidden directories need to be displayed first), and create a new file pre-commit in it (the current user needs to have execution permissions). The content is roughly as follows:The above mysql user, password, and dbname must become your own.
Support @samoay's answer.
But there is a tip, the pre-commit hook is a client-side hook.
You will need to copy this hook file to your co-developers if they need it.
git hooks
is your good partner