Last active
December 17, 2015 22:39
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to use
<
and>
instead of<
and>
.