Update Cached Credentials in Git Repository
Git repository
Git

Context

If you have cached your git credentials for a repository or globally, a couple of scenarios might arise:

  1. Cached credentials need to be updated for a single repository, or globally
  2. 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
Update Cached Credentials in Git Repository
Be The First

Join our list to get instant access to new articles and weekly newsletter.

Tagged on:
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x