git: 'credential-cache' is not a git command

Big McLargeHuge picture Big McLargeHuge · Jul 27, 2012 · Viewed 157.4k times · Source

I followed these instructions to the letter, including the part about password caching. It seems like the instructions are wrong, because every time I git push origin master I get this error:

git: 'credential-cache' is not a git command. See 'get --help'.

... at which point I am forced to enter my username and password. After doing so, I am presented with the same error message again, followed by the output from git push.

Here is the contents of my .gitconfig file:

[user]
    name = myusername
    email = [email protected]
[credential]
    helper = cache

To be clear, after I installed Git and ran Git Bash, here is exactly what I typed:

git config --global user.name "myusername"
git config --global user.email "[email protected]"
git config --global credential.helper cache

Please help. This is so frustrating!

Answer

Nate Cook picture Nate Cook · Aug 9, 2012

From a blog I found:

"This [git-credential-cache] doesn’t work for Windows systems as git-credential-cache communicates through a Unix socket."

Git for Windows

Since msysgit has been superseded by Git for Windows, using Git for Windows is now the easiest option. Some versions of the Git for Windows installer (e.g. 2.7.4) have a checkbox during the install to enable the Git Credential Manager. Here is a screenshot:

screenshot of Git For Windows 2.7.4 install wizard

Still using msysgit? For msysgit versions 1.8.1 and above

The wincred helper was added in msysgit 1.8.1. Use it as follows:

git config --global credential.helper wincred

For msysgit versions older than 1.8.1

First, download git-credential-winstore and install it in your git bin directory.

Next, make sure that the directory containing git.cmd is in your Path environment variable. The default directory for this is C:\Program Files (x86)\Git\cmd on a 64-bit system or C:\Program Files\Git\cmd on a 32-bit system. An easy way to test this is to launch a command prompt and type git. If you don't get a list of git commands, then it's not set up correctly.

Finally, launch a command prompt and type:

git config --global credential.helper winstore

Or you can edit your .gitconfig file manually:

[credential]
    helper = winstore

Once you've done this, you can manage your git credentials through Windows Credential Manager which you can pull up via the Windows Control Panel.