5

Seems like a simple problem but I can't find a solution, in my git config credentials stored in the cache(username and personal access token) the git config --list returns the credential info like this

credential.helper=cache

Is it possible to see the credentials from the cache, I tried the following three locations

  1. (repository_home) /.git/config - there is no info about the username and password

  2. ~/.gitconfig - file not found in the repo folder

SwissCodeMen
  • 3,359
  • 4
  • 15
  • 26
shellakkshellu
  • 4,908
  • 15
  • 59
  • 110

2 Answers2

9

From git-credential git credential fill could be helpful here, you need to input host and protocol details to get username and password.

$ git credential fill
protocol=https
host=example.com

Output:

protocol=https
host=example.com
username=bob
password=secret
Vijay
  • 528
  • 3
  • 8
4

It is possible for you to query a particular set of credentials from the credential helper, but there isn't a part of the credential helper protocol that allows you to query all credentials. In general, this is hard, because a credential helper can respond to all credentials that match a pattern, such as https://*.example.org or https://github.com/bk2204/*, and that pattern need not match any simple pattern that can be expressed (for example, the helper could have intimate knowledge about which repositories a user has access to based on LDAP).

For the cache credential helper, there isn't a way to enumerate those credentials.

If you want to look up the credentials for a particular URL, the easiest way to do that is like this:

echo url=https://github.com/git/git.git | git credential fill

That will print the credentials that any credential helper knows about. You can see more about the protocol in the gitcredentials(7) man page.

bk2204
  • 48,483
  • 5
  • 42
  • 63