How to add more commands to Git Bash?

Solution 1:

There are two versions of Git that you are likely to be using - the msysgit distribution or Cygwin.

Installing Additional Utilities For Cygwin

Although you might have only installed Git as a part of your Cygwin install (if you used Cygwin), Cygwin has a program called setup.exe which you can use to add packages. Essentially, all you have to do is run setup.exe and pick out what programs you want installed when you get to the Select Packages window. The introduction here provides a good overview with images that detail the process.

Cygwin's installer is smart enough to figure out that you have a preexisting installation, and it will add packages to your installation (instead of nuking it and starting over).

MSYS

The other version of Git you are probably using (if not Cygwin) is msysgit. Because msysgit installs a minimal Unix environment which is not really compatible with MinGW, you'll end up having to install the MinGW suite beside msysgit. The MinGW Getting Started page gives a detailed overview on how to go about getting MinGW installed - since I have no experience with MinGW personally, all I can really do is refer you to their instructions.

You'll then have to migrate your msysgit installation into MinGW. This can be accomplished by doing the following (taken from here). After the following sequence is done, MinGW should find your Git installation.

cd GITDIR # Where GITDIR is wherever inside Program Files you put Git
cp bin/git* /MINGW/bin # Where MINGW is wherever you put MinGW
cp -r libexec/git* /MINGW/libexec
cp -r share/git* /MINGW/share

Solution 2:

With recent Git for Windows installations, installing additional shell scripts and programs is pretty easy.

Simply put the executables into C:\Program Files\Git\usr\bin (%ProgramFiles%\Git\usr\bin).

I recommend installing git using chocolatey choco install git --params "/GitAndUnixToolsOnPath /WindowsTerminal", because you can update git (and all other tools installed with chocolatey) by executing choco upgrade all.

Example for git-fresh

Copy the file git-fresh to C:\Program Files\Git\usr\bin.

Example for adr-tools

  1. Download a zip package from the releases page
  2. Unzip the package
  3. Copy everything from src/ into C:\Program Files\Git\usr\bin

Solution 3:

to add rsync

You can download the rsync file directly from mysys. Just search the page for rsync and choose the one with the latest date / latest version number.
Unpack this file (e.g. rsync-3.1.3-1-x86_64.pkg.tar.xz) via

tar -xf rsync-3.1.3-1-x86_64.pkg.tar.xz

Then copy rsync at ./usr/bin/rsync.exe and paste it into the /usr/bin folder of your Git installation.
On my machine, that is C:/Program Files/Git/usr/bin/

You can see the location of your Git installation via

where git

Here is a GitHub gist by "hisplan" (Jaeyoung Chun) that has instructions along with a link to the 3.1.3-1 version of rsync: add-rsync-to-git-bash.

Note: I could not unpack the rsync-3.1.3-1-x86_64.pkg.tar.xz file directly into the Git folder, because permissions did not allow it. And Git Bash does not have sudo.
But I could unpack it directly into my Downloads folder no problem.
It's just as well, because you only need the rsync.exe file anyway.

Solution 4:

If you are using msysgit a simple option is to just install MinGW and then add the MINGW path to the .bashrc file you are using for your Git installation:

    PATH=$PATH:/MINGW/msys/1.0/bin

...where MINGW is where you installed MinGW

That way you can use the MinGW tools directly from your Git bash installation, and if you need another bash tool you can just install it to MinGW.