git: 'credential-cache' is not a git command
Asked Answered
C

22

332

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!

Cadence answered 27/7, 2012 at 17:52 Comment(7)
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.Legra
@Wally +1 Thanks, your command worked for me only after removing --global.Rob
Possible duplicate of Is there a way to skip password typing when using https:// githubDebark
you can alternatively remove the message by modifying .git/config file manually (i.e remove the lines below [credential])Basrelief
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.Unsex
Accepted and popular answers below are now out of date, refer to https://mcmap.net/q/13471/-git-39-credential-cache-39-is-not-a-git-commandBrainstorming
For those still getting this message after running a git fetch or pull cmd, check the config files manually: git config --global -e and git config --local -e In trying to reset my credentials in Windows, I accidently added a line to the local file causing the error. To remove the credentials I followed stackoverflow.com/questions/15381198/… which worked.Georgia
R
379

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.

Ration answered 9/8, 2012 at 18:6 Comment(13)
gitcredentialstore.codeplex.com contains FAQ. It helped me to install winstore successfully. Binary crashes unless you run it from git-bash.Termagant
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''Bedouin
mine throws an unhandled exception and dies -- System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)Andros
I had to follow the step on this link to completely get it working: stackoverflow.com/questions/13107833/…Udell
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?Farrahfarrand
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. :(Stereobate
This has been essentially superseded by the wincred manager included with msysgit.Homegrown
If you are using git through cygwin, you can place git-credential-winstore in the same directory as your git executable (probably /bin).Grapeshot
How do I update these settings if I've already installed without selecting the right option? Do I have to reinstall at that point?Trismus
@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.)Ration
@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'."Trismus
@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: stackoverflow.com/questions/20060572/…Ration
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!))Thralldom
R
89

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

Restless answered 8/3, 2014 at 11:12 Comment(2)
Note that this is not as secure as the in-memory cache. also the 'wincred' option is outdated.Cyanite
This was answered 7 years ago. Not sure what the current state of msysgit isRestless
D
38
  1. Run git config --global credential.helper wincred
  2. Go to: CONTROL PANEL\CREDENTIAL MANAGER\WINDOWS CREDENTIAL\GENERIC CREDENTIAL
  3. Click in add a credential in Internet or network address: add git:https://{username}.github.com
    User: {name}
    Password: {Password}
Dietetics answered 31/12, 2015 at 3:18 Comment(6)
Credential Manager is in User Accounts and Family Safety in Windows 7Lycaon
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.Legge
%windir%\explorer.exe shell:::{1206F5F1-0569-412C-8FEC-3204630DFB70} from the console will start the Credential Manager as well.Lemniscate
Thanks, my issue is fixed :)Platt
What about Azure git repo? I only have the clone URL as https://<user>@dev.azure.com/<my-org>/<azure-project>/_git/<repo-name>. When I enter this as Internet or web address, it is invalid.Freezer
I figured it out^^. In case of Azure repos, we can use either HTTPS or SSH connection. I had to configure git://<org-name>@dev.azure.com/<org-name> 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.Freezer
S
29

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

git config --global credential.helper wincred
Skeet answered 26/2, 2014 at 17:16 Comment(0)
C
26

For git version >=1.7.10 (check with git --version), use this method (from reference):

Windows:

git config --global credential.helper wincred

Mac:

git config --global credential.helper osxkeychain
Chickamauga answered 17/11, 2015 at 17:48 Comment(1)
On Mac. Do git config --global credential.helper osxkeychainAim
B
18

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:

Brainstorming answered 1/11, 2018 at 16:45 Comment(1)
This worked for me except I had to add --replace-all as well as I had multiple credential.helper entries in my config.Aristarchus
P
11

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'.

Pitchfork answered 25/12, 2017 at 16:5 Comment(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.Tailwind
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 helperUpi
D
11

This worked for me:

git credential-manager-core configure
Dynamoelectric answered 7/4, 2022 at 13:38 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Gustatory
C
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

Classical answered 24/5, 2013 at 21:47 Comment(1)
This is the answer I was looking for. Microsoft has started maintaining this project. It stores the passwords in the windows credential store.Nicaragua
K
8

I was also getting similar error when I tried to use command "git pull" from master branch.

Error: "git: 'credential-manager' is not a git command. See 'git --help'." 

I executed below two commands and issue got resolved.

$ git config --global --unset credential.helper
$ git config credential.helper store
Karyosome answered 9/3, 2022 at 14:53 Comment(0)
P
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

Prize answered 17/9, 2012 at 16:3 Comment(2)
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.Trismus
@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.Prize
A
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."

Andros answered 24/10, 2013 at 20:51 Comment(0)
A
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
Adenoidectomy answered 19/8, 2018 at 18:5 Comment(1)
I think the [credentials] key can be removed entirely.Delossantos
D
4

On an older Ubuntu Linux system:

git config --global credential.helper store
Delossantos answered 22/10, 2021 at 0:41 Comment(0)
D
2

Dev. 2022 for Git 2.39.0+ and GCM v2.0.877 (Nov. 2022), PR 551:
GCM no core

warning: git-credential-manager-core was renamed to git-credential-manager
warning: see https://aka.ms/gcm/rename for more information

The current packaged credential helper with Git for Windows (2.38.1.windows.1, Oct. 2022), is

 git config credential.helper
 manager

 where git-credential-manager-core
 c:\Program Files\Git\mingw64\bin\git-credential-manager.exe

Up to Oct. 2022, it was manager-core.

This is after GCM (Git Credential Manager): microsoft/Git-Credential-Manager/

Git Credential Manager (GCM) is a secure Git credential helper built on .NET that runs on Windows, macOS, and Linux. It aims to provide a consistent and secure authentication experience, including multi-factor auth, to every major source control hosting service and platform.

GCM supports (in alphabetical order) Azure DevOps, Azure DevOps Server (formerly Team Foundation Server), Bitbucket, GitHub, and GitLab.
Compare to Git's built-in credential helpers (Windows: wincred, macOS: osxkeychain, Linux: gnome-keyring/libsecret), which provide single-factor authentication support for username/password only.

GCM replaces both the .NET Framework-based Git Credential Manager for Windows and the Java-based Git Credential Manager for Mac and Linux.

Note that the latest release v2.0.866 (Nov. 2022) drops -core suffix from entry executable (PR 551)

Rename the main entry executable from git-credential-manager-core(.exe) to simply git-credential-manager(.exe), now that the older GCM4W has been removed from the Git for Windows project as an option (and the GCMC project has been renamed).

To help with migration somewhat, create symlinks and shim/copy-executables for the original executable name "git-credential-manager-core(.exe)" for consumers who have not updated to the new version.


With Git 2.34 (Q4 2021), unix socket start to be considered for Git for Windows:

See commit bb390b1, commit 245670c, commit 0fdcfa2 (14 Sep 2021) by Carlo Marcelo Arenas Belón (carenas).
(Merged by Junio C Hamano -- gitster -- in commit c2e7990, 23 Sep 2021)

git-compat-util: include declaration for unix sockets in windows

Signed-off-by: Carlo Marcelo Arenas Belón

Available since Windows 10 release 1803 and Windows Server 2019.

NO_UNIX_SOCKETS is still the default for Windows builds, as they need to keep backward compatibility with releases up to Windows 7, but allow including the header otherwise.

Decorticate answered 13/8, 2021 at 7:35 Comment(3)
So it sounds like the Git update I do tomorrow (Nov 2022) might break my current install? Just like the update I did yesterday (Oct 2022) broke an install that was working fine for YEARS? Sigh... If the install is going to use a new name ... why doesn't it update ~/.gitconfig automatically? Or at least tell the user to update ~/.gitconfig manually?Tugman
@Tugman I agree, this is unfortunate. And can be reported in Git For Windows issues once this is released.Decorticate
Anyway - thank you for the comprehensive, up-to-date info on this thread. +1: much appreciated!Tugman
C
2

I literally just went through this!

  1. Download Git Credential Manager Core and Install it: https://github.com/microsoft/Git-Credential-Manager-Core#download-and-install
  2. Go to the Account Settings > Emails on GitHub. Your should see something like this: enter image description here
  3. The highlighted email is system generated to keep your private email private. Now copy that and use it in the next step
  4. Configure git:
 git config --global user.name "yourusername"
 git config --global user.email "[email protected]"
 git config --global credential.helper cache

Now, your git commands should work again.

Minor note: I'm using Linux Mint. YMMV

Additional note: There is a bug in Git Credential Manager Core v 2.0.567 in their Debian backage. Please install v2.0.474 before the new version is out.

Candent answered 14/11, 2021 at 4:25 Comment(1)
Simply installing the latest version of Git (for me it was at gitforwindows.org), fixed everything.Oddment
L
2

Another efficient workaround is:

1- Go to control panel and add your credentials for github.com like this:

Windows Credentials for GitHub

2- go to CMD and enter these commands:

  • a- cd %localappdata%\Atlassian\SourceTree\git_local\mingw32\bin\
  • b- git.exe config --edit --system
  • c- correct last line with: helper = manager
  • d- Save the new config file by clicking on CTRL+C then typing :wq then hit Enter

update configuration: helper = manager

This works perfectly for me!

Linter answered 26/12, 2021 at 4:5 Comment(1)
What is CMD and where is it?Noakes
P
2

In my case this command solved the issue:

git config --global credential.helper manager-core --replace-all

for using the new net-core credential manager.

Pallmall answered 25/6, 2022 at 13:21 Comment(0)
W
1

I had three different helper= entries in my .gitconfig's [credential] section, one of them empty. Deleting the other two and keeping helper=wincred solved the problem for me.

BTW: I don't know why, but I didn't find my .gitconfig right away. I found it then in C:\Users\username.

Which answered 12/1, 2022 at 15:53 Comment(1)
SUGGESTION: If you use Git bash (or happen to be in a MacOS or Linux terminal prompt), your .gitconfig should be here: ~/.gitconfigTugman
C
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!

Colo answered 10/1, 2020 at 8:29 Comment(0)
M
0

On mac run following command:

git config --global credential.helper osxkeychain

Metopic answered 3/8, 2021 at 17:10 Comment(0)
D
-1

My original answer turned out to not be very useful even for myself, so I looked a bit more into it, and I found a hack (albeit somewhat complicated).

So, I use git under MSYS2, and I would like to use credential-cache, to just remember my password temporarily (and I haven't seen such a use case with wincred or other Windows-applicable approaches).

Basically, this requires a hack in https://github.com/git/git/blob/55144cc/builtin/credential-cache--daemon.c#L239 - instead of die-ing in that line, we'd like to proceed.

So, first of all, we want to build git under MSYS2.

  • Problem 1: You cannot just build the proper https://github.com/git/git under MSYS2, linking stage will fail with "src/git/cache.h:1262: undefined reference to `win32_has_dos_drive_prefix'" and similar messages

So, we need to build the actual git as used in MSYS2. First, check versions:

$ git --version
git version 2.33.0
$ pacman -Ss git | grep installed # msys/git 2.33.0-1 (VCS) [installed]

Then, as per https://www.msys2.org/wiki/Creating-Packages/, we can do this:

$ git clone "https://github.com/msys2/MSYS2-packages"
$ cd MSYS2-packages/
$ cd git
$ makepkg -sCLf
==> Making package: git 2.33.0-1 (Thu, Sep 23, 2021 12:47:33 PM)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Installing missing dependencies...
...
make[1]: Entering directory '/c/src/MSYS2-packages/git/src/git-2.33.0'
make[1]: 'GIT-VERSION-FILE' is up to date.
make[1]: Leaving directory '/c/src/MSYS2-packages/git/src/git-2.33.0'
sed -e '1s|#!.*/sh|#!/bin/sh|' git-subtree.sh >git-subtree
chmod +x git-subtree
make: Leaving directory '/c/src/MSYS2-packages/git/src/git-2.33.0/contrib/subtree'
==> Starting check()...

Note here:

  • This build process first ends up in a ASCIIDOC/XMLTO part, which like takes half an hour on my machine
  • Then it ends up in a *** prove *** part which takes even longer, but can be interrupted with Ctrl-C, and the built executables will not be erased.

So, now we want to do a hack in the source; note:

  • If we do a hack in the source, we do NOT want to use makepkg -sCLf, because that will erase the source directory (along with all the built .exe artefacts), and then reconstruct it before build

So, we make our hack with sed, and then build:

$ sed -i 's/die(_(permissions_advice), dir);/fprintf(stderr, "Permissions on cached credentials socket directory %s are too loose, but HACK: going on\\n", dir);/' ./src/git-2.33.0/builtin/credential-cache--daemon.c
$ (cd src/git-2.33.0/; make)
    CC builtin/credential-cache--daemon.o
    LINK git.exe
...
    SUBDIR templates

At this point, note that the hack ends up in at least three executables, which can be confirmed with:

$ grep -ao ....HACK........ ./src/git-2.33.0/git-credential-cache--daemon.exe
$ grep -ao ....HACK........ ./src/git-2.33.0/git-credential-cache.exe
$ grep -ao ....HACK........ ./src/git-2.33.0/git.exe

... and I could only get this to work, after replacing all three:

# backup the original files:

$ mv /usr/lib/git-core/git-credential-cache--daemon.exe /usr/lib/git-core/__git-credential-cache--daemon_orig.exe
$ mv -v /usr/lib/git-core/git-credential-cache.exe /usr/lib/git-core/__git-credential-cache__orig.exe
$ mv -v /usr/bin/git.exe /usr/bin/__git_orig.exe
$ mv -v /usr/lib/git-core/git.exe /usr/lib/git-core/__git_orig.exe

# copy over the hacked files:

cp -v ./src/git-2.33.0/git-credential-cache--daemon.exe /usr/lib/git-core/
cp -v ./src/git-2.33.0/git-credential-cache.exe /usr/lib/git-core/
cp -v ./src/git-2.33.0/git.exe /usr/bin/
cp -v ./src/git-2.33.0/git.exe /usr/lib/git-core/

And at this point, credential-cache started working also for me on MSYS2 (caching passwords for a limited amount of time); it's just that it dumps the hacked line when starting up:

$ git pull
Password for 'https://[email protected]':
Permissions on cached credentials socket directory /home/user/.cache/git/credential are too loose, but HACK: going on
Already up to date.

# second pull, password is cached
$ git pull
Already up to date.

A bit tricky, but seems to work.

PS: A tricky thing was, that I originally replaced die with just a printf to stdout, but that kept on failing; it turns out, stdout is used for interprocess communication, and for this to succeed, something apparently answers ok\0 on stdout which is three bytes; so the solution was to print the notice to stderr instead.


(original answer):

While not responsive to the question exactly as asked, this was the most appropriate question I could find, to document this as an answer:

I use git under MSYS2 in Windows 10, which currently has the version:

$ git --version
git version 2.32.0

I typically just want git to cache my password for a limited time (maybe 10 minutes or so) and then forget about it; and I haven't yet seen uses of wincred or other Windows-specific credential manager with that use case.

That being said, turns out for me there is an "easy fix" - basically, the first time credential manager runs, it is fine; it is only upon subsequent uses that I get:

$ git push
Password for 'http://[email protected]':
fatal: The permissions on your socket directory are too loose; other
users may be able to read your cached credentials. Consider running:

        chmod 0700 /home/user/.cache/git/credential
fatal: cache daemon did not start:
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
...

So, basically, the fix is to delete the credential directory - thereafter, the credential cache manager runs as if for the first time, and caches the passwords for a limited time - just as I want it:

$ rm -rf ~/.cache/git/credential


# note below, the very first pull still asks for a password:

$ git pull
Password for 'http://[email protected]':
Already up to date.

# ... but the second pull does not, it uses credentials cache

$ git pull
Already up to date.

Good enough for me, I guess :)

EDIT: not really, I've experienced that immediately after this, if you try a pull in another tab, the error returns.

Darbydarce answered 13/8, 2021 at 7:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.