Git涂抹过滤器 [英] Git smudge filter

查看:116
本文介绍了Git涂抹过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个过滤器,以便在结帐时将注入一些与git相关的信息到我的文件中,并在提交时删除此信息。我已经证实,当我提交文件时,它已被正确清理。此外,如果我删除文件,然后做一个结帐该文件被适当的污迹。

I am trying to setup a filter so that on checkout it will inject some git related information to my file and on commit it will remove this information. I have verified that when I commit the file it is properly cleaned. Also if I delete the file and then do a checkout the file is properly smudged.

我的问题如下。 如果我对该文件进行了更改并且提交了更改,则涂抹过滤器不会运行。这是预期的行为吗?有没有办法让污迹过滤器在提交时运行? (也许通过一个提交后立即结帐?)

My problem is the following. If I make a change to the file and I commit the change, the smudge filter does not run. Is this the expected behavior? Is there a way to have the smudge filter run on commit? (perhaps by having a commit followed immediately by a checkout?)

推荐答案

你可能会更好模板文件,可以通过使用类似于 git rev-parse HEAD git描述的构建步骤将其转换为具有嵌入的提交信息的被忽略的实际文件来检索当前的提交信息。

You would probably be better off with a template file that can be transformed to an ignored real file with embedded commit information by a build step which uses something like git rev-parse HEAD or git describe to retrieve the current commit information.

这篇关于Git涂抹过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆