Skip to content

Instantly share code, notes, and snippets.

@AndreiTelteu
Last active October 12, 2015 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiTelteu/34fd74c77207dcf09788 to your computer and use it in GitHub Desktop.
Save AndreiTelteu/34fd74c77207dcf09788 to your computer and use it in GitHub Desktop.
Dumping the structure of a database on each commit, and staging that modification for the next commit.

Create or open the file .git/hooks/pre-commit and paste the following code inside it:

#!/bin/sh

mysqldump \
	--no-data \
	--dump-date=false \
	--result-file=$PWD/dbdump.sql \
	--log-error='/dev/null' \
	--user='username' \
	--password='password' \
	'database-name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment