Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force git to always ask for a password

I work on several computers, and I would make sure than git never stores my password while I push. So in short I want git to always ask for my github password.

Is that possible?

I am frustrated than on Mac, for some reason it always store my password in a keychain and I have to remove it manually each time.

I'm using the command line.

EDIT:

This answer gave me a clue to solve the problem:

How do I disable git's credential helper for a single repository?

In the terminal run this:

git config --local credential.helper ''

Alternatively you can edit your .git/config file and have this:

[credential] helper = ''

I don't have the root password (for some reason an admin password is not a valid root password, go figure).

like image 324
turbochicken Avatar asked Feb 16 '18 11:02

turbochicken


People also ask

How do I permanently add my Git credentials?

To save username and password in Git, open your “GitHub” remote repository and copy its “URL”. Then, launch “Git Bash”, paste the “URL” with the “$ git clone” command, specify the credential and execute it. Lastly, run the “$ git config –global credential. helper store” command to save the credential in the “.

How do I fix Git always asking for credentials?

You can avoid being prompted for your password by configuring Git to cache your credentials for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.

Why does Git ask for password every time?

Why Git Keeps Prompting you for Username and Password. Using HTTPS remote URL is useful if you need to work through strict firewalls and proxies but this also means that you'll get prompted for your GitHub username and password each time you pull or push your code to your repository.


1 Answers

git config --global --unset credential.helper
git config --system --unset credential.helper

In Windows: Open User Accounts by clicking the Start button Picture of the Start button, clicking Control Panel, clicking User Accounts and Family Safety (or clicking User Accounts, if you are connected to a network domain), and then clicking User Accounts. In the left pane, click Manage your credentials. Windows 7: Control Panel\User Accounts\Credential Manager

Trick: https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage you can change remember permission timeout to 0 (zero).

macOS

Try running /Applications/Utilities/Keychain Access enter image description here

enter image description here

Right click, choose Delete

If you want use command line from macOS Terminal, type

git credential-osxkeychain erase
host=github.com
protocol=https

enter image description here

like image 100
Do Nhu Vy Avatar answered Oct 28 '22 22:10

Do Nhu Vy