简体   繁体   中英

Git pre-commit hook not adding file on Windows

I have a pre-commit hook that's running a mysqldump to keep track of MySQL. I'm trying to add that dump to the commit, but for some reasons it won't.

The code:

#!/bin/sh

rm -f database.sql

exec "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" --skip-comments -u root --password=password my-database > database.sql

git add database.sql

The file is created, but not added to the commit. Running TortoiseGit on Windows 7.

I don't know if it will help you, but here a step by step guide, how it works on my windows 10 machine with xampplite.

  1. go to your project git

  2. go to "hooks\\"

  3. create file "pre-commit" (without file ending)

  4. go to file properties and give full access to windows user

  5. open pre-commit and paste:

#!/bin/sh

"C:\\xampplite\\mysql\\bin\\mysqldump.exe" -u dbuser -ppassword database_name > database_name.sql

git add database_name.sql exit 0

(-u username -ppassword databasename > file.sql)

file will be stored in project root. between -p and password is NO space.

Now, before every commit a mysql dump will be done and added to the commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM