I have successfully installed and configured msysGit Portable on my flash drive, and have used it to pull and push GitHub repos. However, I seem to always have to kludge the
The command used to launch git bash is:
C:\Windows\SysWOW64\cmd.exe /c ""C:\Prog\Git\1.7.1\bin\sh.exe" --login -i"
I just tried the following in a DOS session:
C:\>C:\Windows\SysWOW64\cmd.exe /c ""C:\Prog\Git\1.7.1\bin\sh.exe" --login -i"
VonC@XXX /c/
$ echo $HOME
/c/Users/VonC
By default, $HOME$%HOMEPATH%, but if I force %HOME%:
set HOME=/another/path
and then launch the same bash session:
C:\>C:\Windows\SysWOW64\cmd.exe /c ""C:\Prog\Git\1.7.1\bin\sh.exe" --login -i"
VonC@XXX /c/
$ echo $HOME
/another/path
So if you wrap the bash call by a script setting the HOME to:
%~dp0 : the path of the wrapper on your USB key%~d1\your\path: with %~d1 being the drive letter (of your usb key if your wrapper is on it), you should be able to force HOME to whatever value you need.
Note (November 2011): since then, the OP dgw has written his own wrapper:
git-bash-portable.bat:
@echo off
rem Copyright (C): 2010 Voyagerfan5761
rem http://technobabbl.es/
set USERPROFILE=%~dp0
set HOMEDRIVE=%~d0
set HOMEPATH=%~p0
set HOME=%~dp0
set HISTFILE=%USERPROFILE%.bash_history
rem set BASHRC=%USERPROFILE%.bashrc
git-bash.bat
The article "Portable Git for Windows: setting the $HOME environment variable to allow complete portability (including SSL keys and configuration for use with GitHub)" also add useful information.
However, if you install Git on a portable drive, you'll want your settings to travel with the installation—which obviously they won't if it is looking for them in a folder which may not exist on other computers.
So, what we need to do is tell Portable Git to treat a specific location within its own folder as the home folder; that way we can copy the whole Git folder anywhere we like and the settings will travel with it.