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 SSH support.
Specifically, in order for SSH to find my key files, I have to follow these instructions to start a second instance of ssh-agent and then ssh-add my key every time I run git-bash.bat.
Using the output of ssh -v git@github.com to debug I see that msysGit defaults to my Windows user directory to look for keys. It can’t do that; I need it to look in its own directory on the portable drive.
How can I force $HOME to be the program’s own folder?
Update for broken Vox link
Instructions from this page are similar to the now-broken link I originally posted. Quoted below. Also here’s the webarchive of original Vox article.
However, if you try this and get:
% ssh-add Could not open a connection to your authentication agent.then your session is not running under the ssh-agent. You can get around this by restarting a new shell under the agent by running:
exec ssh-agent bashwhere you can replace bash with the shell of your choice. Once you do this, you should be able to run ssh-add to load your key for that shell.
The command used to launch git bash is:
I just tried the following in a DOS session:
By default, $HOME$%HOMEPATH%, but if I force %HOME%:
and then launch the same bash session:
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%~d1being 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:The article "Portable Git for Windows: setting the
$HOMEenvironment variable to allow complete portability (including SSL keys and configuration for use with GitHub)" also add useful information.