流浪汉——节省机器当前状态当git推吗? - Vagrant - does it save machine current state when git push?

- 此内容更新于:2016-02-03
主题:

普里的流浪汉,试图理解这个概念,我从git克隆项目,然后运行,我做了一些修改的机器上创建数据库表,然后如果我做git推动所有的提交,所有流浪的变化发展框保持可用下一个git克隆在不同的机器上,如果别人做的

原文:

Preety new to vagrant, trying to understand the concept, ok i cloned the project from git, then run vagrant up, i made some changes on the machine like database tables creation, and then if I do git push all the commits, does all changes in vagrant development box stay available on next git clone on different machine, if someone else do vagrant up?

网友:首先,如果你之前没有从事过任何推什么推。你可能无法写信给流浪的存储库,所以即使你试图推动一个提交,它将被拒绝。如果你想与他人分享配置,你应该叉的库,所以你有你自己的副本,然后把你的提交和让别人使用你的而不是原始的。

(原文:Firstly, if you didn't commit anything before you pushed then nothing will get pushed. You probably won't be able to write to the Vagrant repository, so even if you tried to push a commit, it would be rejected. If you want to share configuration with others, you should fork the repository so you have your own copy of it, then push your commits and get others to use yours instead of the original.)

解决方案:
它取决于你在git存储库保存但一般vm不存储在回购所以答案是否定的。通常的工作流程是:你git克隆一个项目,有一个定义你会改变Vagrantfile(框引用,共享项目…)和运行这个构建VM本地你可以改变VM,摧毁,重建,等等所有这些都是在本地如果你检查你的项目的变化,你会发现如果VM文件变化的一部分,但是我真的怀疑它会这样做,也没有实实在在的利益。下一个人会从你的项目将会继承相同的克隆而不是虚拟机内容。如果你想要工作在VM(像软件安装,数据库创建…)和与他人分享,你需要看看流浪的供应
原文:

It would depend what you save in your git repo but generally VMs are not stored within the repo so the answer is no.

The usual workflow is :

  1. you git clone a project where there's a Vagrantfile defined
  2. you might make change to the Vagrantfile (box reference, shared project ...) and run vagrant up
  3. this will build your VM locally
  4. you can make change to the VM, destroy, rebuild, etc. all those is done locally
  5. if you check the changes on of your project, you will see if the VM files are part of the change, but I really doubt it would be and there is no real benefits in doing so.
  6. the next person who will clone from your project will inherit the same vagrantfile but not the VM content.

If you want to have things done inside the VM (like software installation, DB creation ...) and shared with others, you would need to look at vagrant provisioning