Thanks!  This solution accomplished what I needed, with one slight change 
to handle file non-existance:

    gitconfig = Pathname.new("#{Dir.home}/.gitconfig")
    config.vm.provision :shell, :inline => "echo -e '#{gitconfig.read()}' > 
'/home/vagrant/.gitconfig'", privileged: false if gitconfig.exist?

I suspect it will break if the .gitconfig file contains any single quotes, 
but that's not a problem I'm facing currently.

I hope Vagrant eventually adds support for syncing a single file (instead 
of a whole folder), since that would also solve the problem of keeping the 
guest version in sync with the host version.  I've just opened an issue 
suggesting it:

    https://github.com/mitchellh/vagrant/issues/3021

-ofer

On Tuesday, October 1, 2013 11:52:31 AM UTC-4, Janusz Słota wrote:
>
> On Wednesday, 9 May 2012 21:37:08 UTC+1, Eric Clemmons wrote:
>
>> How can I copy the user's `~/.gitconfig` to my Vagrant VM? 
>>
>>
> I did this way (with Vagrant 1.3.3):
>
> config.vm.provision :shell, :inline => "echo -e 
> '#{File.read("#{Dir.home}/.gitconfig")}' > '/home/vagrant/.gitconfig'"
>
> I also uploaded my ssh key there with this:
>
> config.vm.provision :shell, :inline => "echo -e 
> '#{File.read("#{Dir.home}/.ssh/id_rsa")}' > '/home/vagrant/.ssh/id_rsa'"
>
> Regards
> Janusz
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to