Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to unsync a subfolder in Vagrant?

Tags:

vagrant

There are few subfolders in my project folder that wouldn't need to be synced to the guest machine. (In particular the .git folder, which contains >800 files.) Is there a way to unsync subfolders of a synced folder in Vagrant? Or how should I prevent unneeded folders from being synced?

Disabling sync this way doesn't seem to work, when /vagrant/ is synced by default:

config.vm.synced_folder "www/kisa/.git/", "/vagrant/www/kisa/.git/", disabled: true
like image 277
mikkohei13 Avatar asked Mar 01 '14 11:03

mikkohei13


1 Answers

Normally (with vboxsf, vmhgfs, NFS, ...) the syncing is done by mounting the specified directory from the host to the guest. For performance reasons there should be no need to prevent some content from "syncing", as the data is not transferred unless you access it from the guest. If you write the data on the guest but don't want to sync it back to the host, easiest is to write it somewhere else. =)

The upcoming Vagrant 1.5 will include rsync synced folders which will support rsync__exclude option. Some cloud provider plugins (aws, digital_ocean, ..) already use rsync, but support for excluding depends on the provider. In some cases you just have to sync only the wanted folders separately. You can disable the default sync with

config.vm.synced_folder ".", "/vagrant", disabled: true
like image 121
tmatilai Avatar answered Oct 20 '22 19:10

tmatilai