Skip to content

Instantly share code, notes, and snippets.

@shrwnsan
Last active December 17, 2015 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shrwnsan/5683601 to your computer and use it in GitHub Desktop.
Save shrwnsan/5683601 to your computer and use it in GitHub Desktop.
Git: Useful if you are doing dev between multiple machines (e.g. local or dev environments). Based on "Synchronizing a MySQL Database with Git and Git Hooks" > http://ben.kulbertis.org/2011/10/synchronizing-a-mysql-database-with-git-and-git-hooks/ Note: I'm using the following in OSX.
#!/bin/sh
cd /path/to/your/repo/
gunzip -v < [database].sql.gz | mysql -u [mysql_user] -p[mysql_password] [database]
# Note:
# No need to have these comments in the file...
# This file's location @ /path/to/your/repo/.git/hooks/post-merge
# Be sure to make this file executable via:
# sudo chmod +x /path/to/your/repo/.git/hooks/post-merge
#!/bin/sh
mysqldump -h localhost -u [mysql_user] -p[mysql_password] --skip-extended-insert [database] | gzip > /path/to/your/repo/[database].sql.gz
cd /path/to/your/repo/
git add [database].sql.gz
# Note:
# No need to have these comments in the file...
# This file's location @ /path/to/your/repo/.git/hooks/pre-commit
# Be sure to make this file executable via:
# sudo chmod +x /path/to/your/repo/.git/hooks/pre-commit
@shrwnsan
Copy link
Author

Updated to use < and > instead of &lt; and &gt;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment