Workflow suggestions for working with VMs

I’m fairly new to git, and I do development inside of a VM (Virtual Machine). Assume I’m setting up or working with repos on GitHub.

I’m curious about the efficacy of different workflows I could employ. I see three off-hand:

  1. GitHub -> VM; do work; VM -> GitHub

  2. GitHub -> Host; copy files from host into VM; do work; copy files back to Host; Host -> GitHub

  3. GitHub -> Host; Host ->VM; do work; VM -> Host; Host -> GitHub

Personally, I don’t like (1); historically, I backup all files from inside the VM to the Host, in case the VM crashes and I cannot recover anything inside of it.

So it boils down to whether I can use one tool (git) to move files between GitHub <–> Host and Host <–> VM, or if I use two different tools (eg., BeyondCompare to sync up Host and VM files).

Has anybody written up anything discussing the pros and cons of this situation. It seems like it would be common enough that there might be something around, but I haven’t found anything.

But if you’ve got any experience with this situation, I’d love to hear your findings and recommendations.

I personally don’t see a problem with 1). Could you explain why that is not effecient for you?

The only other way I can think of is setting up a Git server on the host and then adding that git server as another remote to your repo in the VM. Then you could just push to both your repo and host git server.