Using GitPortable on Windows

Gitportable

Git is a great tool to manage your code and collaborate on code. Originating from the Opensource community, it can also be used on a Windows computer.

In order to use git from the commandline on Windows, and be able to use it from a thumbdrive, I use GitPortable

To do this, go the link above, download GitPortable and extract it to a folder on your thumbdrive. If you start GitPortable.exe, it loads the GUI version. Not what we want.

To change this, AppAppInfoLauncherGitPortable.ini In that file, change the ProgramExecutable to git-bash.exe. Verify the path. Mine looks like this:

[Launch]
;ProgramExecutable=Git\cmd\git-gui.exe
ProgramExecutable=Git\git-bash.exe
CommandLineArguments=--cd-to-home
WorkingDirectory=%PAL:DataDir%\home
WaitForEXE1=wish.exe
WaitForEXE2=git-bash.exe
WaitForEXE3=gitk.exe
WaitForEXE4=git.exe
DirectoryMoveOK=yes
MinOS=Vista

[Environment]
HOME=%PAL:DataDir%\home

[FileWrite1]
Type=Replace
File=%PAL:DataDir%\home\.gitconfig
Find=%PAL:LastDrive:ForwardSlash%%PAL:LastPackagePartialDir:ForwardSlash%
Replace=%PAL:Drive:ForwardSlash%%PAL:PackagePartialDir:ForwardSlash%

[FileWrite2]
Type=Replace
File=%PAL:DataDir%\home\.gitconfig
Find=%PAL:LastPortableAppsBaseDir:ForwardSlash%
Replace=%PAL:PortableAppsBaseDir:ForwardSlash%

[FileWrite3]
Type=Replace
File=%PAL:DataDir%\home\.gitconfig
Find=%PAL:LastDrive%/
Replace=%PAL:Drive%/

Now try to run GitPortable.exe. You should see a terminal version. Check the git version:

git --version

If you like to use git over ssh, it's possible to create a ssh config file with info on your ssh connections. In the Datahome there should be a .ssh folder, and if there's not, create one. Create a file "config" and put your favourite ssh info there. For instance, to connect to a server with a ssh key:

Host myserver
        Hostname myserver.fqdn
        Port 22
        User myuser
        IdentityFile /F/.ssh/id_mykey
        ControlMaster auto
        ControlPath ~/.ssh/control:%h:%p:%r

This should make it easier to run a portable git from the commandline.