有没有办法让一个永远不会提交的补丁,只会改变工作副本? [英] Is there a way to have a patch that is never commited, only changes the working copy?
问题描述
- / * SimpleMonitor monitor = new SimpleMonitor(new) );
- machine.attachMonitor(monitor); * /
+ SimpleMonitor monitor = new SimpleMonitor();
+ machine.attachMonitor(monitor);
也就是说,当我在本地创建时,我想启用SimpleMonitor,但我总是希望检查在代码中保留它的注释。 SimpleMonitor打印出一些关于我的测试用例内部发生的详细信息。
当然,我可以永远不会将此更改添加到提交中。
有没有办法使用git,即使使用'git add。'或'git add -A'等等,我总是可以排除这种改变,这样git会跳过这个改变?
想法是,这是一个只在工作副本顶部的增量。如果存在一些整洁的诡计,或者使用分支或其他东西,那么请告诉我一些关于它的信息。 为你的文件声明一个内容过滤器驱动程序(一个'clean'脚本),它会在签入时自动评论右边的行。
这是在的图片href =http://git-scm.com/book/en/ =nofollow noreferrer> Git Book )
git config filter。< filtername> .clean ./< ; filterscript>
您可以使用< filterscript>
版本化在您的回购。
I would like to modify a test to comment in some extra code:
- /*SimpleMonitor monitor = new SimpleMonitor();
- machine.attachMonitor(monitor);*/
+ SimpleMonitor monitor = new SimpleMonitor();
+ machine.attachMonitor(monitor);
That is, when I am building locally I would like to enable SimpleMonitor, but I always want the checked in code to keep it commented out. SimpleMonitor prints out some verbose information about what is going on internally in my test cases.
Of course I can just never add this change to the commit.
Is there a way with git that I can always exclude this change, even when using 'git add .' or 'git add -A' and so on, such that git will skip over this change?
The idea is that this is a delta that sits on top of a working copy only. If there is some neat trick with stash or using a branch or something else, do please tell me about it.
You could declare for your file a content filter driver ( a 'clean' script) which would automatically, on checkin, comment the right line.
That is done in a .gitattributes
file: see for instance "Does .gitignore
have an equivalent for version controlled files?".
(image from "Customizing Git Attributes" from the Git Book)
git config filter.<filtername>.clean ./<filterscript>
You can have <filterscript>
versioned in your repo.
这篇关于有没有办法让一个永远不会提交的补丁,只会改变工作副本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!