292

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 = myusername@myemaildomain.com
[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 "myusername@myemaildomain.com"
git config --global credential.helper cache

Please help. This is so frustrating!

Big McLargeHuge
  • 11,456
  • 8
  • 64
  • 92
  • 61
    To remove the message, "git: 'credential-cache' is not a git command.", run "git config --global --unset credential.helper", then you can follow the instructions below. – Wallace Kelly Jan 24 '14 at 23:18
  • 6
    @Wally +1 Thanks, your command worked for me only after removing `--global`. – Web_Designer Nov 22 '14 at 07:26
  • Possible duplicate of [Is there a way to skip password typing when using https:// github](http://stackoverflow.com/questions/5343068/is-there-a-way-to-skip-password-typing-when-using-https-github) – Michael Freidgeim Mar 01 '16 at 04:48
  • 1
    you can alternatively remove the message by modifying .git/config file manually (i.e remove the lines below [credential]) – tarikakyol Aug 11 '16 at 06:40
  • FWIW for those reading the various Windows suggestions below, `git config credential.helper cache` _did_ work for me with Cygwin git version 2.13.2. – Flash Sheridan Sep 07 '17 at 23:17
  • Accepted and popular answers below are now out of date, refer to https://stackoverflow.com/a/53105688/3066295 – TT-- Nov 01 '18 at 16:46

12 Answers12

342

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.

Nate Cook
  • 7,577
  • 5
  • 44
  • 36
  • 5
    http://gitcredentialstore.codeplex.com/ contains FAQ. It helped me to install winstore successfully. Binary crashes unless you run it from git-bash. – ruruskyi Dec 21 '12 at 10:30
  • 8
    FYI I had to install with explicit admin rights. Without it, I was getting error "git: 'credential-winstore' is not a git command. See 'git --help'". My .gitconfig now looks a bit different also, with the [credential line] having "helper = !'C:\\Users\\Malachi\\AppData\\Roaming\\GitCredStore\\git-credential-winstore.exe'' – Malachi Sep 15 '13 at 23:57
  • mine throws an unhandled exception and dies -- System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) – Andrew Sep 19 '13 at 19:03
  • I had to follow the step on this link to completely get it working: http://stackoverflow.com/questions/13107833/git-credential-winstore-prompt-does-not-work-with-self-hosted-repositories – Yogesh Jindal Oct 25 '13 at 20:51
  • 1
    Is there a reason as to why they would use Unix sockets in a multi-platform application? And if so, why does git-credential-winstore does not ship with the Windows version of Git by default? – Domi Nov 24 '13 at 05:49
  • 3
    The git-credential-winstore tool is not working for me. It used to, but suddenly I'm getting prompted all over the place. I've checked .git-config and the Windows Credential Manager and everything is there that should be. It's simply not working and I really don't have any idea why. :( – Chris McKenzie Dec 10 '13 at 18:13
  • This has been essentially superseded by the wincred manager included with msysgit. – nimish Jun 10 '14 at 13:15
  • If you are using **git** through **cygwin**, you can place *git-credential-winstore* in the same directory as your *git* executable (probably `/bin`). – palswim Sep 30 '15 at 19:06
  • How do I update these settings if I've already installed without selecting the right option? Do I have to reinstall at that point? – Buttle Butkus May 04 '16 at 00:42
  • @ButtleButkus In that case I believe you'll just execute `git config --global credential.helper wincred` at the command line. (This depends on which version of git you have installed of course.) – Nate Cook May 04 '16 at 00:49
  • @NateCook I decided to update to latest version for windows, apparently 2.8.2. Mine was 2.7-ish from last October. So I chose the correct settings this time but I'm getting this error when running `git fetch`: "git: 'credential-cache' is not a git command. See 'git --help'." – Buttle Butkus May 04 '16 at 01:14
  • @ButtleButkus Do you by chance have multiple versions of git installed? (Maybe check the path with `where git` at the command line.) Also check the answers to this related question to see if it helps: http://stackoverflow.com/questions/20060572/git-credential-cache-is-not-a-git-command-remove-setting – Nate Cook May 04 '16 at 15:21
  • Last method is really useful for git installations in MSys2, which works better for me because it has a different home location. (We have network home drives at work. (Yuck!)) – jpaugh Jun 28 '18 at 20:33
67

Looks like git now comes with wincred out-of-the-box on Windows (msysgit):

git config --global credential.helper wincred

Reference: https://github.com/msysgit/git/commit/e2770979fec968a25ac21e34f9082bc17a71a780

A T
  • 10,508
  • 14
  • 85
  • 137
  • Note that this is not as secure as the in-memory cache. also the 'wincred' option is outdated. – Xaser Mar 31 '21 at 10:01
  • 1
    This was answered 7 years ago. Not sure what the current state of msysgit is – A T Mar 31 '21 at 13:45
32

First run git config --global credential.helper wincred

Then go to: CONTROL PANEL\CREDENTIAL MANAGER\WINDOWS CREDENTIAL\GENERIC CREDENTIAL

then click in add a credential in Internet or network address: add git:https://{username}.github.com

User: {name}

Password: {Password}

Ivandro Jao
  • 1,814
  • 3
  • 21
  • 22
  • 2
    Credential Manager is in User Accounts and Family Safety in Windows 7 – Casey Murray Feb 27 '16 at 17:21
  • 1
    THANK YOU! It took me an hour to find out how to fix my Windows Credential Manager after changing my domain password. Holy moly, what a maze. – SadBunny Dec 05 '16 at 11:46
  • 3
    `%windir%\explorer.exe shell:::{1206F5F1-0569-412C-8FEC-3204630DFB70}` from the console will start the Credential Manager as well. – Jeroen Wiert Pluimers Jul 22 '17 at 13:19
  • 1
    Thanks, my issue is fixed :) – Diallo Jul 28 '17 at 13:29
  • What about `Azure git repo`? I only have the clone URL as `https://@dev.azure.com///_git/`. When I enter this as Internet or web address, it is invalid. – Jay Mar 09 '21 at 16:48
  • I figured it out^^. In case of Azure repos, we can use either HTTPS or SSH connection. I had to configure `git://@dev.azure.com/` as Internet address, `org-name` as username and `PAT token` as password. Then, I had to execute `$ git config --global credential.helper wincred` to set proper credential helper. – Jay Mar 09 '21 at 17:00
27

I faced this problem while using AptanaStudio3 on windows7. This helped me:

git config --global credential.helper wincred

Code taken from here

Community
  • 1
  • 1
Ikrom
  • 3,635
  • 4
  • 42
  • 68
15

First find the version you are using for GIT.

using this command : git --version

if you have a newer version than 1.7.10.

Then simply use this this command.

Windows:

git config --global credential.helper wincred

MAC

git config --global credential.helper osxkeychain

Reference

Sireesh Yarlagadda
  • 10,572
  • 2
  • 65
  • 71
15

A similar error is 'credential-wincred' is not a git command

The accepted and popular answers are now out of date...

wincred is for the project git-credential-winstore which is no longer maintained.

It was replaced by Git-Credential-Manager-for-Windows maintained by Microsoft open source.

Download the release as zip file from link above and extract contents to

\cygwin\usr\libexec\git-core

(or \cygwin64\usr\libexec\git-core as it may be)

Then enable it, (by setting the global .gitconfig) - execute:

git config --global credential.helper manager

How to use

No further config is needed.

It works [automatically] when credentials are needed.

For example, when pushing to Azure DevOps, it opens a window and initializes an oauth2 flow to get your token.

ref:

Community
  • 1
  • 1
TT--
  • 2,186
  • 21
  • 41
10

There is now a much easier way to setup Git password caching by double clicking a small exe on Windows. The program is still based on git-credential-winstore mentioned by the top voted answer, although the project has been moved from GitHub to http://gitcredentialstore.codeplex.com/

You can download the exe (and a binary for Mac) from this blog post: https://github.com/blog/1104-credential-caching-for-wrist-friendly-git-usage

Saheed
  • 6,514
  • 1
  • 26
  • 27
  • This is the answer I was looking for. Microsoft has started maintaining this project. It stores the passwords in the windows credential store. – Gordolio Oct 08 '16 at 20:59
9

I fixed this issue by removing the credential section from the config of specific project:

  • Just typed: git config -e
  • Inside the editor I removed the whole section [credential] helper = cache.

This removed the annoying message :

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

Pini Cheyni
  • 3,741
  • 1
  • 31
  • 45
  • 2
    I tried many solutions from above and this is the only one that worked. I just went to my .git folder, opened the config file and deleted [credential] helper = global (I set it to "global" accidentally). Thanks a lot Pini Cheyni. – Filip Savic Apr 03 '18 at 11:25
  • 1
    I'm glad I could help – Pini Cheyni Apr 04 '18 at 06:53
  • This is, indeed, the easier way to do. BTW, you can add `--global` if you cannot find the `helper`. You can also change `cache` to `manager` which is the default value for `helper` – Han Sep 02 '20 at 02:20
7

For the sake of others who come on this issue, I had this same problem in Ubuntu (namely that my passwords weren't caching, despite having set the option correctly, and getting the error git: 'credential-cache' is not a git command.), until I found out that this feature is only available in Git 1.7.9 and above.

Being on an older distribution of Ubuntu (Natty; I'm a stubborn Gnome 2 user) the version in the repo was git version 1.7.4.1. I used the following PPA to upgrade: https://launchpad.net/~git-core/+archive/ppa

Johann
  • 3,675
  • 3
  • 36
  • 36
  • 1
    I am still getting `git: 'credential-cache' is not a git command.` even after upgrading to version 2.8.2 on Windows, even though the credential cache is working! I probably created this problem by using some `git config` command before. – Buttle Butkus May 04 '16 at 01:16
  • 1
    @ButtleButkus git config alters either `~/.gitconfig` or the repo-local `.git/config`, depending on whether the `--global` flag was used. Look at those two files for anything related to credentials. – Johann Feb 27 '19 at 17:49
5

For the sake of others having this issue - I landed here because I tried to get cute with how I set up a new github repository, but per the setup page credential helper doesn't work unless you clone a repository.

"Tip: The credential helper only works when you clone an HTTPS repository URL. If you use the SSH repository URL instead, SSH keys are used for authentication. This guide offers help generating and using an SSH key pair."

Andrew
  • 8,441
  • 8
  • 41
  • 57
4

I realize I'm a little late to the conversation, but I encountered the exact same issue In my git config I had two entries credentials…

In my .gitconfig file

[credential]
helper = cached
[credentials]
helper = wincred

The Fix: Changed my .gitconfig file to the settings below

[credential]
helper = wincred
[credentials]
helper = wincred
0

We had the same issue with our Azure DevOps repositories after our domain changed, i.e. from @xy.com to @xyz.com. To fix this issue, we generated a fresh personal access token with the following permissions:

Code: read & write Packaging: read

Then we opened the Windows Credential Manager, added a new generic windows credential with the following details:

Internet or network address: "git:{projectname}@dev.azure.com/{projectname}" - alternatively you should use your git repository name here.
User name: "Personal Access Token"
Password: {The generated Personal Access Token}

Afterwards all our git operations were working again. Hope this helps someone else!