【问题标题】:Git pre-commit hook not adding file on WindowsGit预提交钩子不在Windows上添加文件
【发布时间】:2014-05-17 04:24:49
【问题描述】:

我有一个预提交钩子,它运行一个 mysqldump 来跟踪 MySQL。 我正在尝试将该转储添加到提交中,但由于某些原因它不会。

代码:

#!/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

文件已创建,但未添加到提交中。 在 Windows 7 上运行 TortoiseGit。

【问题讨论】:

  • 文件是否在正确的目录下创建?
  • 您是否尝试过重新安装 Windows?

标签: windows git githooks tortoisegit


【解决方案1】:

我不知道它是否会对您有所帮助,但这里有一个分步指南,它是如何在我的带有 xampplite 的 Windows 10 机器上工作的。

  1. 转到你的项目 git

  2. 转到“挂钩”

  3. 创建文件“预提交”(没有文件结尾)

  4. 转到文件属性并授予 windows 用户完全访问权限

  5. 打开预提交并粘贴:

#!/bin/sh

"C:\xampplite\mysql\bin\mysqldump.exe" -u dbuser -ppassword 数据库名 > 数据库名.sql

git add database_name.sql 退出 0

(-u 用户名 -ppassword 数据库名 > file.sql)

文件将存储在项目根目录中。 -p 和密码之间没有空格。

现在,在每次提交之前,都会完成 mysql 转储并将其添加到提交中。

【讨论】:

    猜你喜欢
    • 2018-05-21
    • 2019-01-17
    • 2013-12-15
    • 2012-08-23
    • 1970-01-01
    • 2016-10-16
    • 1970-01-01
    相关资源
    最近更新 更多