37

I am using Cygwin and Git. Every time I push/pull to a repo on Bitbucket with a https url I am asked to enter a password. Is there a way to store these credentials (like with ssh-keys)?

I tried to install Windows Credential Store for Git but I can't get it to work with cygwin's Git.

Thanks!

Update:

I found my answer here: Is there a way to skip password typing when using https:// on GitHub?

Summarized:

Remember passwords for 15 minutes (default):

git config --global credential.helper cache

Remember passwords for 10 hours:

git config --global credential.helper 'cache --timeout=36000'

Store passwords (didn't try this):

git config --global credential.helper store

Reset:

git config --unset --global credential.helper

Cim

Community
  • 1
  • 1
Cim
  • 371
  • 1
  • 3
  • 5
  • 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) –  Sep 08 '13 at 18:04
  • 2
    next time if you find the answer, just write an answer to your own question (you can and it's a good practice) instead of writing editing the question to put the answer in – RubenLaguna Apr 30 '14 at 09:34
  • 1
    I tried the "store password" option and it worked, even after rebooting cygwin. Didn't try more. – Michele Di Cosmo May 31 '15 at 11:51

2 Answers2

31

The way OP answered his own question is one way to go about it.

The Windows Credential Store project was discontinued in 2015. Its original author suggests to use Git Credential Manager for Windows, maintained by Microsoft. Their installer is focused on Git for Windows, however the program itself works well with Cygwin, you just have to install it manually.

Go the GCMW's latest release, download the zip file (not the installer), extract its contents (only .dll and .exe files are needed) to C:\cygwin\usr\libexec\git-core\ for 32-bit Cygwin, or C:\cygwin64\usr\libexec\git-core\ for 64-bit Cygwin. Reference

To get git to use GCMW, execute: git config --global credential.helper manager

To get GUI prompts for credentials, execute: git config --global credential.modalprompt true

If you want this to be a per-repository setting, remove the --global option.

bobbogo
  • 14,989
  • 3
  • 48
  • 57
Gene Pavlovsky
  • 1,515
  • 17
  • 14
  • 5
    A final tip, make sure to `chmod a+x *.{exe,dll}` after copying these files into `git-core`. Otherwise, you'll see an error like "'credential-manager' is not a git command" because git-credential-manager.exe isn't executable. – joelhardi Dec 01 '17 at 16:49
  • This solution works for MSYS2 as well. The path to dump the `*.dll` and `*.exe` in is `C:\msys64\usr\lib\git-core`. – Daniel Feb 12 '20 at 01:38
  • 4
    GCMFW is now(or soon?) obsolete. The following tweaked solution works for the new cross-platform git-credential-manager-core. After moving all exe/dlls from the Git Credential Manager Core zip just use `git config --global credential.helper manager-core` The new utility is here: https://github.com/microsoft/Git-Credential-Manager-Core/releases – Naxin Jan 19 '21 at 05:19
  • 2023 update: the solution still works, but you also have to copy *.config files apart from EXEs and DLLs. – PKua Jun 19 '23 at 15:41
19

I made Windows Credential Store working with cygwin. The only thing that needs to be changed is global ~/.gitconfig file.

Change 'helper' value which can be found usually at the end of the file to the following:

[credential]
    helper = !'/cygdrive/C/Users/<YOUR-ACCOUNT-NAME>/AppData/Roaming/GitCredStore/git-credential-winstore.exe'

For an explanation, cygwin simply uses different paths and the value must follow the rules of course.

Marek Suscak
  • 1,086
  • 10
  • 25
  • This is gold, thanks! Everyone make sure to install cygwins git (via the cygwin installer). Otherwise you will not get this solution to work. – Riscie Jul 12 '15 at 09:01
  • 6
    Worked for me! But I'm using the more recent `git-credential-manager` and my path's slightly different: `!'/cygdrive/C/Users//AppData/Local/Programs/Microsoft Git Credential Manager for Windows/git-credential-manager.exe'` – theDrake Dec 24 '15 at 04:17