Rilcon42 Rilcon42 - 1 month ago 8
Git Question

git configuration to prompt for username on push

I have several git repositories on my computer. Some of them ask for my username every time I push, but others do not.

Why is this? Is there a global git configuration or setting I need to change?

Running linux mint if it matters.

Answer

To be sure about your git local repository status, inside your git local repository folder type command

git config --list

to see affected configuration.


We have 2 type of Git configuration:

Global (If you use 2 or more than git servers, I don't recommend this way)

git config --global user.name "Mr. Joe"
git config --global user.email "joe@example.com"


Repository level (If you use many git servers, It's recommended), at repo R1:

git config user.name "Mr. Rilcon"
git config user.email "rilcon@example.com"

at repo R2:

git config user.name "Mr. Happy"
git config user.email "saturday@example.com"

Then you will avoid problems, Git won't ask you username or password many times.