Command Line Git Operations Repeatedly Prompt for Username and Password
1月 6, 2025
·
1 分钟阅读时长
·
188
字
·
-阅读
-评论
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
Username for 'https://git.xxx.com': Password for 'https://git.xxx.com':
Solution
- Open the terminal and execute
git config --global credential.helper storecommand to store credentials locally. - Execute the
git pull/pushoperation, enter username and password once, and it won’t prompt again for subsequent operations.
Command Scope Explanation
- When using the
--globalparameter, the setting affects all Git repositories for the current user. The configuration is saved in the~/.gitconfigfile in the user’s home directory. - If you want it to only affect the current repository, remove the
--globalparameter and executegit config credential.helper store. The configuration will be saved in the.git/configfile of the current repository.
Alternative Solutions
If the above operation doesn’t work, try the following steps:
- First, clear existing credential configuration:
git config --global --unset credential.helper
- Reset credential storage:
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.

