[英]how to ignore files in kiln/mercurial using tortoise hg “that are part of the repository”
We use tortoise hg with Kiln. 我们用窑龟用hg。 In my vs 2010 c# project there are some files that are part of the repository but I would like tortoise hg to ignore them when I make a commit.
在我的vs 2010 c#项目中,有一些文件是存储库的一部分但是我想在我提交时忽略它们。 For eg., say in a login screen I may hard code the userid, password for testing.
例如,在登录屏幕中,我可以硬编码用户ID,密码用于测试。 I dont really want this file considered during a commit.
我真的不希望在提交期间考虑此文件。 I understand .hgignore file but this really works for files that are not part of the repo.
我理解.hgignore文件,但这确实适用于不属于repo的文件。 Any trick in tortoise hg to ignore files that are part of the repo ?
在togise 中有什么技巧可以忽略属于repo的文件 ? (so they do not show up as modified (M) during a commit.) thanks
(因此在提交期间它们不会显示为已修改的(M)。)谢谢
I always use a combination of .hgignore and BeforeBuild
(in the .csproj file) for things like this. 对于像这样的事情,我总是使用.hgignore和
BeforeBuild
(在.csproj文件中)的组合。
In one of my pet projects, I have the following setup: 在我的一个宠物项目中,我有以下设置:
App.config
contains my real hardcoded user id and password for testing. App.config
包含我用于测试的真实硬编码用户ID和密码。
App.config.example
is identical, but with fake data like "dummy_user" and "dummy_pw". App.config.example
是相同的,但有假数据,如“dummy_user”和“dummy_pw”。
App.config
is not part of the repository, and it's ignored (in .hgignore
). App.config
不存储库的一部分,它忽略(在.hgignore
)。
App.config.example
is part of the repository. App.config.example
是存储库的一部分。
Then, I have the following in the BeforeBuild
target in the .csproj file of my solution: 然后,我在解决方案的.csproj文件中的
BeforeBuild
目标中有以下内容:
<Target Name="BeforeBuild">
<Copy
Condition="!Exists('App.config')"
SourceFiles="App.config.example"
DestinationFiles="App.config"/>
</Target>
All this together has the following effect: 所有这些一起具有以下效果:
.example
file (and then he can just put his real login data into the newly created App.config
file). .example
文件自动创建(然后他可以将他真正的登录数据放入新创建的App.config
文件中)。 App.config
with real hardcoded user data already exists, it won't be overwritten when building because the BeforeBuild event will only happen if App.config
does not already exist App.config
与真正的硬编码的用户数据已经存在,它不会被建立,因为如果BeforeBuild事件只会发生在覆盖App.config
已不存在 The answer by Christian is the right one, but I want to mention that TortoiseHg supports what you want with their Auto Exclude List . Christian的答案是正确的,但我想提一下TortoiseHg通过他们的自动排除列表支持你想要的东西。
One problem with an exclude list is that it cannot work with merges: you must commit all files when you merge and so you'll have to do a little dance with shelve, merge, commit, and unshelve. 排除列表的一个问题是它无法使用合并:您必须在合并时提交所有文件,因此您必须与搁置,合并,提交和取消搁置进行一些跳舞。
When you do a TortoiseHG commit, there is a list of files with checkboxes by them. 当您执行TortoiseHG提交时,会有一个包含复选框的文件列表。 Deselect the files you do not want comitted.
取消选择您不想要的文件。
Or, on the command line, do a commit of the form hg commit --exclude "pattern"
, where pattern is defined in the hg man page. 或者,在命令行上,执行提交形式
hg commit --exclude "pattern"
,其中pattern在hg手册页中定义。
你可以随时使用hg忘记 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.