防止 web.config 在 SVN 中提交

发布于 2024-11-28 21:14:28 字数 589 浏览 2 评论 0原文

进行 SVN 提交时是否可以阻止 web.config 文件被提交?我有以下 SVN 全局忽略模式集,但它仍然不能阻止它。如果我用“web.config”替换“*.config”,它仍然不能阻止它。

http://screencast.com/t/fLKoZhYykYG

全局忽略模式:

*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store */bin */obj bin obj aspnet_client *.tmp */legacy legacy *.suo *.user *.config

======== =============

简单答案(尽管下面的实用程序非常好):

右键单击 Web.config 文件,然后选择“删除并添加到忽略列表”。文件上的图标将变成红色“X”。然后提交更改。它不会删除物理文件,但会从 SVN 中删除它,因此它不会再提交。

Is it possible to prevent the web.config file from being committed when doing an SVN commit? I have the following SVN Global ignore pattern set, but it still doesn't prevent it. If I replace "*.config" with "web.config" it still doesn't prevent it.

http://screencast.com/t/fLKoZhYykYG

Global ignore pattern:

*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store */bin */obj bin obj aspnet_client *.tmp */legacy legacy *.suo *.user *.config

=====================

Simple Answer (even though the utility below is very good):

Right click the Web.config file, and choose "Delete and Add to Ignore List". The icon on the file will turn into a red "X". Then commit the change. It will not delete the physical file, but it'll delete it from SVN so it won't commit anymore.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

九厘米的零° 2024-12-05 21:14:29

全局忽略实际上适用于您在存储库中不需要的文件类型,因此您不会意外添加它们。这就是为什么它们都是后缀。另外,它们只是该一台计算机的本地文件,因此无法真正强制执行它。您可以在每个目录中设置 svn:ignore ,并且可以将其设置为您不设置的特定文件或目录添加。

忽略和 svn:ignore 仅适用于存储库中尚未存在的文件,因此如果 web.config 已存在,则无法使用它们。而且,它们不会阻止您有目的地指定您希望该文件位于存储库中。基本上,全局忽略的文件不会显示为 ?当您执行svn status时,如果您执行svn add *,则不会添加。但是,您始终可以执行 svn add web.config 并将其添加到您的存储库中。

如果您确实想确保它永远不会添加,您可以使用我的预提交“Kitchen Sink”挂钩。这个钩子脚本执行许多不同的任务,它可以做的一件事是允许您禁止基于 Glob 或 Regex 模式的文件。如果有人执行 svn add web.config 并尝试提交它,则此预提交挂钩将禁止该事务。

我最近重写了该脚本,您可以下载它并给它一个尝试。您需要 Perl,但我编写的脚本不需要任何可选模块,因此安装非常简单。如果您使用的是 Unix 系统,那么 5.8 版本的 Perl 应该可以正常工作。在 Windows 上,您可以下载 ActiveState Perl 或 Strawberry Perl,预提交挂钩将毫无问题地运行。

我使用挂钩脚本来防止用户添加所有各种 VisualStudio 用户文件或 bin/obj 和 bin/release 目录。我还阻止有人添加 /target 目录。它还可用于允许用户创建标签,但阻止对其进行任何编辑。

The Global ignore is really for file types you don't want in your repository, so you don't accidentally add them. That's why they're all suffixes. Plus, they're only local for that one machine, so there's no way to really enforce it.You can set svn:ignore in each directory and that can be set to specific files or directories you don't to add.

Ignores and svn:ignore only work for files that aren't already in your repository, so you can't use them if web.config is already there. And, they don't stop you from purposefully specifying that you want that file in your repository. Basically, a globally ignored file won't show up with a ? when you do svn status and won't be added if you do a svn add *. However, you can always do a svn add web.config and it'll be added to your repository.

If you really want to make sure it is never added, you can use my pre-commit "Kitchen Sink" hook. This hook script does a lot of different tasks, and one thing it can do is to allow you to ban files based upon Glob or Regex patterns. If someone does an svn add web.config, and tries to commit it, this pre-commit hook will prohibit the transaction.

I've recently rewrote the script, and you can download it and give it a try. You'll need Perl, but I've written the script not to require any optional modules, so installation is pretty simple. If you're on a Unix system, Perl as old as 5.8 should work fine. On Windows, you can download ActiveState Perl or Strawberry Perl and the pre-commit hook will run with no problems.

I use the hook script to prevent users from adding in all the various VisualStudio user files, or the bin/obj and bin/release directories. I also prevent someone adding in a /target directory. It also can be used to allow users to create a tag, but prevent any editing of them.

鹊巢 2024-12-05 21:14:29

右键单击 Web.config 文件,然后选择“删除并添加到忽略列表”。文件上的图标将变成红色“X”。然后提交更改。它不会删除物理文件,但会从 SVN 中删除它,因此它不会再提交。

Right click the Web.config file, and choose "Delete and Add to Ignore List". The icon on the file will turn into a red "X". Then commit the change. It will not delete the physical file, but it'll delete it from SVN so it won't commit anymore.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文