8000 Vagrant · msysgit/msysgit Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Vagrant

dscho edited this page Nov 24, 2014 · 7 revisions

Introduction

Vagrant is a modern way to define the requirements of a project. In the case of msysGit, it allows us to set up a minimal virtual Linux machine for trying out/using Linux Git on Windows without much effort.

Note: while Vagrant makes things easy, quite a bit of bandwidth is required for the initial steps: in total, roughly a gigabyte will need to be downloaded to get started.

How to install

  1. Download and install VirtualBox
  2. Download and install Vagrant
  3. Install msysGit
  4. Run vagrant up in the / directory of msysGit
  5. Run vagrant ssh

Note that the prompt shows that the current directory in the ssh session inside the virtual machine is /vagrant/git and that the files in that directory are suspiciously identical to the /git/ directory in your msysGit installation. This is not by accident. In fact, the /vagrant/ directory inside the virtual machine is the / directory of the hosting msysGit.

To compile and install Git, you will have to run make clean first because msysGit will have built Windows binaries in the same directory (when we will need Linux binaries inside the virtual machine started by Vagrant). After calling make install and export PATH=$HOME/bin:$PATH you will be able to run the Git version built from the source files in /vagrant/git/.

Why?

Git was invented to work with Linux. Over the years, it has become more and more platform-independent, but still support for Linux outshines support for every other platform, including Windows. Therefore it is preferable under certain circumstances to run Git inside Linux in a virtual machine, for example

  • for finding out whether a bug is Windows-specific or not
  • for performance (Linux' filesystem and memory management is better than Windows')
  • for proper 64-bit support (msysGit -- as of 1.8.5.2 -- does not support 64-bit binaries)
  • for current Subversion bindings (it is notoriously hard to compile Subversion bindings into MSys' Perl)
  • etc

Known problems

  • The Linux version of Git was designed to run on Linux file systems. Vagrant exposes msysGit's root directory as /vagrant/ but of course it cannot make up for the Windows file system's lack of support for Unix-style file permissions nor case-sensitive file names. As a consequence, quite a few of the unit tests fail when run in-place.
  • Git cannot be built with Perl's MakeMaker using Vagrant: it tries to create files with double colons in their name (e.g. Git::I18N.3pm) which is not allowed on Windows file systems.
  • If msysGit was started inside a VirtualBox (e.g. to be able to test Git for Windows even on a Linux/MacOSX laptop), VirtualBox will not be able to start the virtual machine (with an error message VERR_VMX_NO_VMX). This is a known problem with VirtualBox.
  • git svn is very slow. Actually, git svn is not very slow. But it is if you run it inside a directory under /vagrant/. The reason is that Linux' superior file system performance cannot come to full play when accessing /vagrant/ -- which really is the msysGit root directory managed by Windows. If you want to benefit from Linux' performance characteristics, you will have to perform the time-critical operations either in /home/vagrant/ inside the virtual machine, or inside a tmpfs.

Tips & Tricks

Use tmpfs

Linux offers a plethora of file systems optimized for different use cases. One of them is tmpfs, a RAM-based file system which keeps all files in virtual memory and is therefore very fast (but does not persist any of the data to disk).

Using such a file system can speed up Git operations quite substantially, in particular when performing disk-intensive operations, such as git filter-branch, git gc or git svn. It is very easy to create a tmpfs-backed file system:

mkdir -p $HOME/tmp
sudo mount -t tmpfs -o size=10G tmpfs $HOME/tmp
cd $HOME/tmp
Clone this wiki locally
0