Git pre-commit 挂钩作为 post-commit
Git pre-commit hook works as a post-commit
标题几乎说明了一切。
在本地存储库中,我有 .git 文件夹,其中包含我的挂钩。我使用我的自定义 Lua 源将当前版本写入文件内部。然后在 pre-commit 挂钩中我有:
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
echo "START" >> E:/Desktop/tmp.txt
exec $LUA_HOME\lua.exe ${PWD}\hooks\pre-commit.lua "${PWD}/lua/autorun/trackassembly_init.lua" "Rev." > E:/Desktop/tmp.txt
我有两个文件。首先,我进行实际更改(源文件)。第二个我用来在(版本文件)中写入当前版本。
每当我使用 TortoiseGit 并执行以下操作时:
1) Modify the source file
2) Repo Directory --> Right Click --> Git Commit "master"
索引中添加了源文件的信息,但没有发现新版本的修改版本文件的踪迹。这导致工作副本和版本文件之间存在差异,TortoiseGit 在目录上放置了一个 (!)。
根据手册:
pre-commit 挂钩首先是 运行,甚至在您输入提交消息之前。它用于检查即将提交的快照,查看您是否忘记了什么,确保测试 运行,或检查您需要在代码中检查的任何内容。从此挂钩退出 non-zero 会中止提交
在git中,您首先进行更改(git add
),然后提交它(git commit
),(然后推送它,但在这里并不重要) . post-commit 挂钩在提交后运行;如果您当时更改了工作副本,则不会影响暂存更改。
标题几乎说明了一切。
在本地存储库中,我有 .git 文件夹,其中包含我的挂钩。我使用我的自定义 Lua 源将当前版本写入文件内部。然后在 pre-commit 挂钩中我有:
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
echo "START" >> E:/Desktop/tmp.txt
exec $LUA_HOME\lua.exe ${PWD}\hooks\pre-commit.lua "${PWD}/lua/autorun/trackassembly_init.lua" "Rev." > E:/Desktop/tmp.txt
我有两个文件。首先,我进行实际更改(源文件)。第二个我用来在(版本文件)中写入当前版本。
每当我使用 TortoiseGit 并执行以下操作时:
1) Modify the source file
2) Repo Directory --> Right Click --> Git Commit "master"
索引中添加了源文件的信息,但没有发现新版本的修改版本文件的踪迹。这导致工作副本和版本文件之间存在差异,TortoiseGit 在目录上放置了一个 (!)。
根据手册:
pre-commit 挂钩首先是 运行,甚至在您输入提交消息之前。它用于检查即将提交的快照,查看您是否忘记了什么,确保测试 运行,或检查您需要在代码中检查的任何内容。从此挂钩退出 non-zero 会中止提交
在git中,您首先进行更改(git add
),然后提交它(git commit
),(然后推送它,但在这里并不重要) . post-commit 挂钩在提交后运行;如果您当时更改了工作副本,则不会影响暂存更改。