部署时版本控制中的配置文件

发布于 2024-09-12 07:18:01 字数 193 浏览 4 评论 0原文

我对配置文件和部署有一个特殊的问题。当我部署项目时,它最终会移动到两个不同的分支:暂存和生产(此处使用 SVN),

我从项目的本地工作副本创建分支。最终的结果是覆盖暂存和开发的配置文件副本,因此我每次部署时都必须手动进入并进行正确的更改。

既然它是一成不变的,那么从 SVN 中完全删除配置文件是否有意义?或者还有其他方法可以做到这一点吗?

I have a particular problem with config files and deployment. When I deploy my project, it eventually moves to two different branches: staging and production (using SVN here)

I make the branch from my local working copy of the project. What this ends up doing is overwriting staging and development's copy of the config files, so I manually have to go in and make the correct changes every time I deploy.

Does it make sense to delete the config files from SVN completely since it's set in stone? Or is there another way in doing this?

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

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

发布评论

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

评论(2

此岸叶落 2024-09-19 07:18:01

我通常做的是在存储库中维护多个配置文件,但不是在实际名称下(例如,在从部署中排除的专用文件夹中)。然后,我的部署脚本将适当的配置文件复制到最终位置。所以我的部署例程是:

  • 签出
  • 编译
  • 运行部署脚本

What I usually do is maintain multiple configuration files in the repository, but not under the actual name (e.g. in a dedicated folder that gets excluded from deployment). My deployment scripts then copy the appropriate config file into the final location. So my deployment routine goes:

  • checkout
  • compile
  • run deployment script
渔村楼浪 2024-09-19 07:18:01

您不想从 SVN 中删除文件 - 因为这会导致 SVN 在您部署时从服务器中删除它们。

SVN 提供了一项名为 svn:ignore 的功能,您可以使用该功能从版本控制中排除一个或多个单独的文件,或者匹配要忽略的文件名模式。基本上,忽略文件意味着 SVN 会将它们保留在每个工作副本或部署服务器上,因此它们在每个地方都可能不同。

有两种方法可以从命令行使用忽略。

答:编辑目录的忽略属性。

  • 使用 cd trunk/blah 更改到包含要忽略的文件的目录。
  • 使用 svn propedit svn:ignore . 编辑此目录的忽略属性。这将打开一个文本编辑器。
  • 在打开的文件中,添加或修改代表您要忽略的文件的行。例如,添加一行*.txt将导致SVN忽略所有以.txt结尾的文件。添加一行config.php将导致SVN忽略config.php文件。
  • 保存并退出文件。
  • 提交属性更改。 svn commit -m "New Ignores"

B:使用单个命令在目录上设置 SVN 忽略属性。

  • 使用 cd trunk/blah 更改到包含要忽略的文件的目录。
  • 使用 svn propset svn:ignore config.php . 来设置 SVN 忽略属性以忽略 config.php 文件。
    • 提交属性更改。 svn commit -m“新忽略”

关于 svn:ignore 的好介绍性文章
官方 SVN 文档。”

You don't want to delete the files from SVN - since that will cause it to delete them from the server when you deploy.

SVN offers a feature called svn: ignore that you can use to exclude one or multiple individual files from version control or match a pattern of filenames to ignore. Basically, ignoring files means that SVN will leave them as they are on each working copy or deployment server, so they can be different in each place.

There are two ways to use ignore from the command line.

A: Edit the ignore properties for a directory.

  • Use cd trunk/blah to change to the directory that contains files you want to ignore.
  • Use svn propedit svn:ignore . to edit the ignore properties for this directory. This will open a text editor.
  • In the file that opens, add or modify lines which will represent the file(s) you want to ignore. For example, adding a line of *.txt will cause SVN to ignore all files ending in .txt. Adding a line of config.php will cause SVN to ignore the config.php file.
  • Save and exit the file.
  • Commit the property change. svn commit -m "New Ignores"

B: Use a single command to set the SVN ignore property on a directory.

  • Use cd trunk/blah to change to the directory that contains files you want to ignore.
  • Use svn propset svn:ignore config.php . to set the SVN ignore property to ignore the config.php file.
    • Commit the property change. svn commit -m "New Ignores"

Good introductory article on svn:ignore.
"Official SVN documentation."

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