Command Line Git Operations Repeatedly Prompt for Username and Password
When executing git pull/push operations in the terminal, it keeps prompting for username and password, even though I’ve already entered them before. Here’s how to solve this issue.
Git Prompting for Username and Password
1 | Username for 'https://git.xxx.com': Password for 'https://git.xxx.com': |
Solution
- Open the terminal and execute
git config --global credential.helper store
command to store credentials locally. - Execute the
git pull/push
operation, enter username and password once, and it won’t prompt again for subsequent operations.
Command Scope Explanation
- When using the
--global
parameter, the setting affects all Git repositories for the current user. The configuration is saved in the~/.gitconfig
file in the user’s home directory. - If you want it to only affect the current repository, remove the
--global
parameter and executegit config credential.helper store
. The configuration will be saved in the.git/config
file of the current repository.
Alternative Solutions
If the above operation doesn’t work, try the following steps:
- First, clear existing credential configuration:
1
git config --global --unset credential.helper
- Reset credential storage:
1
git config --global credential.helper store
At the end
Git is a frequently used tool, so it’s important to document common issues promptly for future reference.