如何从本地机器下载虚拟机​​中的 git 个文件并使它们可更新

How to download git files in virtual machine from local machine and make them updateable

我正在使用 vagrant 进行开发,在 vagrant 中我安装了 ubuntu/xenial64 (Ubuntu 16.04 TLS) 用于 odoo 开发。

在这个带有 ubuntu 的虚拟机中,如果我想将 github 存储库下载到系统本身的文件夹中,我将这样做:

root@ubuntu:~# mkdir /opt/odoo 'create directory
root@ubuntu:~# sudo git clone https://www.github.com/odoo/odoo --depth 1 --branch 10.0 --single-branch /opt/odoo 'download git online

以上完美运行。

如果我想从我的 Windows 机器(主机)下载本地 git 文件怎么办:

C:/GitHub/odoo

进入我的 ubuntu(虚拟机)文件夹:

/opt/odoo

我知道我可以将本地 git 文件从 Windows 复制粘贴到 ubuntu VM(这是可能的),但在这种情况下我需要制作 git ubuntu VM 中的文件可更新,这样如果我在 ubuntu VM 中发出这样的命令:

sudo git fetch upstream 10.0
sudo git pull upstream 10.0

以上命令将从 Windows 获取 git 文件并将其拉入我的 ubuntu 虚拟机,其中原始路径为

C:/GitHub/odoo

这可能吗?

我正在考虑在 ubuntu 中创建一个可以与主机通信的共享目录,其中 ubuntu 可以读取 C:/Github/odoo 中的文件,但我不确定如何在 ubuntu 最小设置中实现这一点,或者这是唯一的方法吗?

I was thinking about making a shared directory in ubuntu that can communicate with the host machine where ubuntu can read the file at C:/Github/odoo but I'm not sure how to achieve this in ubuntu minimal setup or is this the only approach?

你说得对,只需在主机 (windows) 和 VM 之间使用一个共享文件夹,这样任何一个上的更改都会反映在另一个上,你将能够 pull/push 来自 windows 或虚拟机。

只需在你的 vagrant 文件中添加以下内容

config.vm.synced_folder "C:/GitHub/odoo", "/opt/odoo", owner: "root", group: "root"