

Table of Contents
Context
If you have cached your git credentials for a repository or globally, a couple of scenarios might arise:
- Cached credentials need to be updated for a single repository, or globally
- Cached credentials need to be removed for a single repository, or globally
Refer to this article on how to cache git credentials.
Remove Cached Credentials from Git Repository
If you want to remove cached credentials from a specific repository in a terminal, change the directory to the root folder of the repository, and open .git/config file. In the config file add a credentials block as shown below.
# Change directory to the root directory of the repository
cd <repo-dir>
# Open config file from the root directory of the repository
vi .git/config
# Add following lines to config file
[credential]
helper =
# In case you want to apply it globally add the above
# configuration to ~/.gitconfig file
vi ~/.gitconfig
Alternatively, add the above configuration using git command.
# Execute the following from a git repo directory, applicable to that repo only git config credential.helper "" # Execute the following from a git repo directory, for global configuration git config --global credential.helper ""
Update Cached Credentials in Git Repository
In order to update cached credentials first, remove cached credentials following the steps mentioned above. After removal, Git will start asking for credentials in subsequent operations. Then, change the credential cache configuration to ensure credentials are cached. Refer to this article on how to cache git credentials. Here are the steps:
# Execute the following from a git repo directory, applicable to that repo only git config credential.helper store # Execute the following from a git repo directory, for global configuration git config --global credential.helper store
Alternatively, open the .git/config file in a text editor and add credential block as shown below:
# Change directory to the root directory of the repository
cd <repo-dir>
# Open config file from the root directory of the repository
vi .git/config
# Add following lines to config file
[credential]
helper = store
# In case you want to apply it globally add the above
# configuration to ~/.gitconfig file
vi ~/.gitconfig
Join our list to get instant access to new articles and weekly newsletter.

