本文介绍了在提交前提交钩子之前修改文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一个预先提交的钩子来修改代码中的一行,但我甚至不知道从哪里开始。



问题是:



我有一个 KEY

  public static final String APP_KEY =; //在提交前删除密钥!!! 

为了避免将KEY发布到资源库,我想可能git钩子是我们需要手动删除密钥。我查看了)



查看示例o f如何在


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.

See an example of how those filters are declared in "Can git automatically switch between spaces and tabs?"

这篇关于在提交前提交钩子之前修改文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 13:50
查看更多