请从 Subversion 常见问题解答中对此进行解释? “不要使用文件,使用模板”
http://subversion.apache.org/faq.html#ignore-commit
我的项目中有一个文件,每个开发人员都必须更改该文件,但我不希望提交这些本地 mod。如何让“svn commit”忽略该文件?
答案是:不要将该文件置于版本控制之下。相反,将文件的模板置于版本控制之下,例如“file.tmpl”。
然后,在初始“svn checkout”之后,让您的用户(或您的构建系统)将模板的正常操作系统副本复制到正确的文件名,并让用户自定义该副本。该文件没有版本控制,因此永远不会被提交。如果您愿意,您可以将该文件添加到其父目录的 svn:ignore 属性中,这样它就不会显示为“?”在“svn status”命令中。
我在学习 Subversion 时遇到的 .tmpl 文件的唯一用途是钩子文件,它们为您提供一个模板,例如 post-commit.tmpl,其中有一个示例 shell 脚本,您应该重命名它没有.tmpl 并将其放入 hooks
文件夹中。
恐怕我不明白这个常见问题解答的含义。带有 .tmpl 扩展名的文件是否会被 Subversion 忽略?我必须重命名该文件吗?
假设我的系统在服务器上的文件中有 database-config.php
,并且我想在本地计算机上使用反映本地条件的不同 database-config.php
进行开发。我必须将其命名为database-config.php.tmpl
吗?
有人可以逐步告诉我如何按照答案中的说明进行操作吗?
顺便说一句,我知道还有其他类似的问题,但我不认为它们中的任何一个解决了这个特定的常见问题解答问题,或要求将其拼写出来。
http://subversion.apache.org/faq.html#ignore-commit
I have a file in my project that every developer must change, but I don't want those local mods to ever be committed. How can I make 'svn commit' ignore the file?
The answer is: don't put that file under version control. Instead, put a template of the file under version control, something like "file.tmpl".
Then, after the initial 'svn checkout', have your users (or your build system) do a normal OS copy of the template to the proper filename, and have users customize the copy. The file is unversioned, so it will never be committed. And if you wish, you can add the file to its parent directory's svn:ignore property, so it doesn't show up as '?' in the 'svn status' command.
The only use of .tmpl files I've come across in learning about Subversion are the hook files, where they give you a template say post-commit.tmpl which has an example shell script in it, and you're supposed to rename it without the .tmpl and put it in the hooks
folder.
I'm afraid I don't get what this FAQ answer means. Are files with .tmpl extensions somehow ignored by Subversion? Do I have to rename the file?
Say my system has database-config.php
in a file on the server, and I want to develop on my local machine with a different database-config.php
reflecting local conditions. Do I have to call it database-config.php.tmpl
?
Can someone talk me step-by-step through how I would follow the instructions in the answer?
By the way, I'm aware there are other similar questions, but I don't believe any of them addresses this specific FAQ question, or asks for it to be spelled out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 @Wrikken 所说 - 添加具有常见首选设置的最标准文件并将其“存储”在存储库中。现在,当用户签出它时 - 在执行其他操作之前 - 他必须首先:
您可以将模板文件命名为任何名称 - 但强烈建议将其命名为与原始文件名不同的名称。这样,该文件就可以无害地保留在该文件的本地版本中,并且用户必须在使用该文件之前修改该文件。
As stated by @Wrikken - Add the most standard file with common preferred settings and "Store" it in the repository. Now when the user checks it out - before anything elese - He must first:
You can name the template file anything - but yes naming it different from the Original file name - is highly recommended. This way that file can harmlessly sit along the local version of that file, and it will make it compulsory for the user to modify the file before he can use it.