Skip to content
/ git-cred Public

gitcred reads/sets/erases cached credential entries using the configured Git Credential Helper

License

Notifications You must be signed in to change notification settings

VonC/git-cred

Repository files navigation

git-cred

Reads cached credentials using the configured Git credential helper.
(MIT license)

go install github.com/VonC/git-cred@latest

Open in VS Code

Problem

A git credential helper is used to cache HTTPS remote Git hosting service credentials (username/password or token)

You can used that helper to query credentials manually:

credhelper=$(git config credential.helper)
printf "host=github.com\nprotocol=https" | git-credential-${credhelper} get

This works for any Mac/Linux/Windows cached credentials.

And if you want to set a new password/token, it is even more cumbersome:

credhelper=$(git config credential.helper)
printf "host=github.com\nprotocol=https\nusername=VonC\npassword=xxx" | git-credential-${credhelper} set

Goal

  • Replace the complex command line by a tool able to quickly read/set/erase cached credentials, no matter your credential helper.
  • Cross-platform.

Solution

  • git-cred will read your current credential helper
  • By default, in a repository, it will display cached credentials for the current folder/repository

Since the executable follows the naming convention git-xxx (here git-cred or git-cred.exe), that means you can also type:
git cred.
As if "cred" was a git command. It works if the executable git-cred(.exe) is in your $PATH/%PATH%.

get

get is the default command for git-cred.
You do not need to add get.

get, from outside a repository

git cred -u VonC -s github.com
# or (same)
git cred -u VonC -s github.com get

get, from inside a cloned repository folder

cd /path/to/local/github.com/cloned/repository
git cred
# or (same)
git cred get

set

set, from outside a repository

git cred -u VonC -s github.com set <password or token>

set, from inside a cloned repository folder

cd /path/to/local/github.com/cloned/repository
git cred -u VonC set <password or token>

erase

erase, from outside a repository

git cred -u VonC -s github.com erase

erase, from inside a cloned repository folder

cd /path/to/local/github.com/cloned/repository
git cred -u VonC erase

About

gitcred reads/sets/erases cached credential entries using the configured Git Credential Helper

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published