Skip to content

2015

Install Git on Windows via Chocolatey

This post shows how to use Chocolatey to install Git.

Chocolatey

If you do not have Chocolatey, you can install it by following the instructions on chocolatey.org. You may also see this post for instructions on how to set the Chocolatey cache location.

Git

Install Git

In PowerShell as Administrator:

choco install git --params "/GitAndUnixToolsOnPath /NoAutoCrlf"

Close and open PowerShell, so it can pick the updated PATH environment.

Verify

Verify you have git:

git --version
git version 2.6.4.windows.1

Verify you have ssh:

ssh
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port]
           [-Q cipher | cipher-auth | mac | kex | key]
           [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] [user@]hostname [command]

How to use a different cache directory for Chocolatey packages

About Chocolatey

In short, Chocolatey is a package manager for Windows which saves time by automating otherwise manual installation tasks. You can install Chocolatey by following the instructions on chocolatey.org.

Configure Chocolatey's Cache Folder

For security reasons, Chocolatey installs in C:\ProgramData\chocolatey by default. See Why does Chocolatey install where it does? for more information.

Also by default, Chocolatey will download packages in C:\Users\USERNAME\AppData\Local\Temp\chocolatey which might work or not for you. If you need to use a different folder, you can set the cacheLocation key in C:\ProgramData\chocolatey\config\chocolatey.config to a folder of your choice.

For example, to use C:\ChocolateyCache as a cache folder, add <add key="cacheLocation" value="C:\ChocolateyCache" description="Cache location if not TEMP folder." /> to the chocolatey.config file like this:

<?xml version="1.0" encoding="utf-8"?>
<chocolatey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <containsLegacyPackageInstalls>false</containsLegacyPackageInstalls>
  <commandExecutionTimeoutSeconds>0</commandExecutionTimeoutSeconds>
  <config>
    <add key="cacheLocation" value="C:/ChocolateyCache" description="Cache location if not TEMP folder." />
    <add key="containsLegacyPackageInstalls" value="true" description="Install has packages installed prior to 0.9.9 series." />
    <add key="commandExecutionTimeoutSeconds" value="2700" description="Default timeout for command execution." />
    <add key="proxy" value="" description="Explicit proxy location." />
    <add key="proxyUser" value="" description="Optional proxy user." />
    <add key="proxyPassword" value="" description="Optional proxy password. Encrypted." />
  </config>
  <sources>
    <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" priority="0" />
  </sources>
  <features>
    <feature name="checksumFiles" enabled="true" setExplicitly="false" description="Checksum files when pulled in from internet (based on package)." />
    <feature name="autoUninstaller" enabled="false" setExplicitly="false" description="Uninstall from programs and features without requiring an explicit uninstall script." />
    <feature name="allowGlobalConfirmation" enabled="false" setExplicitly="false" description="Prompt for confirmation in scripts or bypass." />
    <feature name="failOnAutoUninstaller" enabled="false" setExplicitly="false" description="Fail if automatic uninstaller fails." />
  </features>
  <apiKeys />
</chocolatey>