GithubHelp home page GithubHelp logo

vonc / git-cred Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 72 KB

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

License: MIT License

Batchfile 25.81% Go 74.19%
git cached credentials credential-helper credential-manager

git-cred's Introduction

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

git-cred's People

Contributors

vonc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

git-cred's Issues

mac darwin fails to build

super cool tool.

I tried to make it work with darwin:
I changed internal/syscall/exec_linux.go to be renamed to exec.go with darwin added to the conditional build args like:

//go:build linux || darwin
// +build linux darwin

Now it builds :)

But I did this but still got errors.

./git-cred get
2022/10/24 13:35:10 exit error exit status 1 []
2022/10/24 13:35:10 exit error exit status 1 []
2022/10/24 13:35:10 Unable to get Credential Helper: error 'unable to get system credential.helper Git config (stderr ''): exit status 1'

If you need help working this out am happy to play with it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.