git-cred

command module
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 8 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳