turbochicken
turbochicken

Reputation: 61

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).

Upvotes: 6

Views: 10552

Answers (2)

Vy Do
Vy Do

Reputation: 52714

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

Upvotes: 6

Mr.Christer
Mr.Christer

Reputation: 802

This as I understand it would be an SSH issue. You do not want to use the MacOS key chain for a certain host i.e. GitHub.

This is my way to achieve this

SSH's default configuration is loaded from ~/.ssh/config (~ is your home directory).

Open that file in your favorite editor and add your GitHub host with the configuration to not store your key in the key chain/agent.

For example

Host <short name for your host, perhaps my-github or github.com>
  Hostname github.com
  UseKeychain no
  AddKeysToAgent no

Note: If you want a rule to apply for all hosts you can use

Host *

If your short name is something other than github.com, say super-server-github edit your <path-to-repo>/.git/config to reflect that as

[remote "origin"]
        url = git@super-server-github:activehacker/gfs.git

Good luck!

Upvotes: 0

Related Questions