我试图编写一个预先提交的钩子来修改代码中的一行,但我甚至不知道从哪里开始。
问题是:
我有一个 KEY
public static final String APP_KEY =; //在提交前删除密钥!!!为了避免将KEY发布到资源库,我想可能git钩子是我们需要手动删除密钥。我查看了 Git Book )
查看示例o f如何在中声明这些过滤器?git能够自动在空格和制表符之间切换吗?
I am trying to write a pre-commit hook that modify a line in my code but I do not know even from where to start.
The problem is:
I have a KEY
public static final String APP_KEY = ""; //DELETE THE KEY BEFORE COMMIT!!!In order to avoid publishing the KEY to the repository I've think maybe git hooks are the thing we need instead of delete the key manually. I've take a look at Customizing git hooks but I do not know how to write the hook.
Is there a way to before commit the changes, delete the KEy and after the commit write the key again?
解决方案That would be done with a content filter driver:
- a clean script which would remove the key on checkin
- a smudge script which would add it back on checkout.
(image from "Customizing Git Attributes" from the Git Book)
See an example of how those filters are declared in "Can git automatically switch between spaces and tabs?"
更多推荐
在提交前提交钩子之前修改文件
发布评论