I develop on Windows (yeah, I hear your jeers, linux users!), so to use Git, I use Git for Windows
However, I use Git For Windows (portable version) so I can keep my dev environment centrally located. This is so I can reuse this environment simply by copying my msysgit directory to a USB drive.
https://github.com/git-for-windows/git/releases/
You'll want the latest 7z file prefixed with PortableGit
in the file name.
Extract the 7z file to a directory of your choosing. For this article, I'll be using c:\PortableGit\
as a reference point.
The last step is loading bash and telling it to use a custom HOME
directory.
-
Create a new directory called
home\portable\
in the folder that you extracted PortableGit to. eg.c:\PortableGit\home\portable
-
Next, create a
.bat
in the mainPortableGit
folder to launch bash to use our customHOME
directory.
In the following code block, we'll be using Mintty as our terminal to launch bash since it comes with PortableGit.
The most important part in the .bat
file is setting our HOME environment variable to use our custom HOME
directory.
Copy the accompanying mintty.bat
file to c:\PortableGit\mintty.bat
.
- Launch Mintty by double-clicking on
mintty.bat
.
The above example uses Mintty, but you could easily modify the .bat
file to use some other terminal like ConEmu.
So the current portable git packages are 7z SFX packages (.7z.exe) and not 7z archives (.7z).
However, you can run the install silently from commandline. 7z SFX executables support command line switches
According to the docs,
-o PATH\PATH\PATH\PATH
sets the path,-y
runs the extractor without prompt,-gm2
completely hides the extraction.Personally, I prefer to use
portablegit.7z.exe -o "out\folder" -y
so I can see the extraction progress barEDIT: so 7z SFX has some weird jargon about command line parameters. Apparently, most SFX configuration file parameters can be passed as command line switches. Exceptions:
AutoInstall
AutoInstallX
Delete
DeleteX
RunProgram
Shortcut
ShortcutX