我只是了解了 vagrant 的基础知识,但我不知道如何在虚拟机中管理我的代码库。
现在我已经为 vagrant 配置设置了一个主存储库,然后我有一个共享 www/文件夹,其中我有一个包含实际代码库的子模块。因此开始的工作流程如下所示:
- git 克隆 user@the_vagrant_config_repo
- git 子模块初始化
- git 子模块更新(现在提取实际的代码库)
- Vagrant 起来
我不喜欢的是我的主要代码库最终成为 vagrant 配置的子模块,但理想情况下我想将该 vagrant 配置保留在存储库中,以便我可以轻松地传递它。
还有其他/更好的方法吗?
最佳答案
我会使用良好的旧环境变量,在本例中为VAGRANT_CWD
:
VAGRANT_CWD can be set to change the working directory of Vagrant. By default, Vagrant uses the current directory you’re in. The working directory is important because it is where Vagrant looks for the Vagrantfile. It also defines how relative paths in the Vagrantfile are expanded, since they’re expanded relative to where the Vagrantfile is found.
通过这种方式,您可以将 Vagrant 配置和代码库保存在两个独立的存储库中。
关于git - 在虚拟机中开发时如何管理代码库(vagrant),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19111284/