Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have git store ONLY my username and not my password?

Tags:

git

I am aware that I can use git config credential.helper to store both my username and password. But I want to ONLY store my username and have the terminal ask for my password each time I push. How is this done?

Something similar to this, but without the password.

$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>
like image 212
kebab-case Avatar asked Feb 03 '19 20:02

kebab-case


Video Answer


1 Answers

Git credential helpers store both usernames and passwords. The design is such that if a username and password combination succeed, then the helper is told to write both items to its store.

If you want to store only the username, and not the password, then you shouldn't use a credential helper. Instead, you should disable the credential helper and write the username in the URL for the remote. For example, you can use git remote set-url origin http://[email protected]/repo.git to set the remote URL for origin to contain your username. Note that if your username contains characters outside of letters and numbers, it may need to be percent-escaped.

like image 150
bk2204 Avatar answered Oct 31 '22 16:10

bk2204