如何创建一个预提交挂钩,在我推送到我的服务器之前跟踪我的 Django 代码中的错误
How to create a pre-commit hook that will track errors from my Django code before I push to my server
我最近才发现什么是预提交挂钩,据我所知,它是一个文件 (.git/hooks/pre-commit)
,它在将更改提交到我的服务器 (DigitalOcean) 之前跟踪我的代码错误.所以我想制作这个文件,但我不知道要添加什么代码。我试图为 Django 项目找到 pre-commit
的示例文件,但找不到。建议表示赞赏。
what I understand it's a file (.git/hooks/pre-commit) that tracks my code for errors before the changes are committed to my server (DigitalOcean)
对我来说,pre-commit
hook 是一个脚本,它将在您在回购中 locally 提交之前执行。如果 "locally" 是 DigitalOcean,那么是的,你是对的。
但是如果 locally 在你的机器上 在推送到 DigitalOcean 之前,那么不:不涉及远程回购:该脚本在提交之前执行,你推(或不推)的事实没有影响。
并且不要忘记 pre-commit
hook can be skipped entirely 无论如何
git commit --no-verify
# or
git commit --n
该脚本的作用是您想要的任何东西。
话虽如此,您可以看到 pre-commit hook example with Django here。
我最近才发现什么是预提交挂钩,据我所知,它是一个文件 (.git/hooks/pre-commit)
,它在将更改提交到我的服务器 (DigitalOcean) 之前跟踪我的代码错误.所以我想制作这个文件,但我不知道要添加什么代码。我试图为 Django 项目找到 pre-commit
的示例文件,但找不到。建议表示赞赏。
what I understand it's a file (.git/hooks/pre-commit) that tracks my code for errors before the changes are committed to my server (DigitalOcean)
对我来说,pre-commit
hook 是一个脚本,它将在您在回购中 locally 提交之前执行。如果 "locally" 是 DigitalOcean,那么是的,你是对的。
但是如果 locally 在你的机器上 在推送到 DigitalOcean 之前,那么不:不涉及远程回购:该脚本在提交之前执行,你推(或不推)的事实没有影响。
并且不要忘记 pre-commit
hook can be skipped entirely 无论如何
git commit --no-verify
# or
git commit --n
该脚本的作用是您想要的任何东西。
话虽如此,您可以看到 pre-commit hook example with Django here。