reset git credentials

How to Reset Git Credentials

Git offers a credential storage that caches git username and password for users, so that they don’t need to manually enter them every time during git authentication. Sometimes you may need to reset git credentials or remove existing user credentials stored in your git client. In this article, we will learn how to reset git credentials. Git user credentials are stored in credential.helper object. You just need to clear it to reset git authentication or remove cached credentials. It is useful if your credentials change and you need to update them in your git client.

How to Reset Git Credentials

You can easily reset git credentials by issuing the following command from terminal or git client.

$ git config --global --unset credential.helper

Once you clear the git credentials, you will be asked to enter git username and password every time git requires user authentication, unless you cache the user credentials once again.

You can easily cache user configuration with the following command.

$ git config --global credential.helper "cache --timeout=timeout_value"

Here are some commonly used examples of setting cache. You need to specify the timeout value in seconds.

# Cache for 1 hour
$ git config --global credential.helper "cache --timeout=3600"

# Cache for 1 day
$ git config --global credential.helper "cache --timeout=86400"

# Cache for 1 week
$ git config --global credential.helper "cache --timeout=604800"

If you want to cache the git use credentials forever, you need to use the timeout value of -1.

# Cache forever
$ git config --global credential.helper "cache --timeout=-1"

In this article, we have learnt how to reset git credentials in your git client. Often users store their git user credentials using credential.helper. But sometimes it may get corrupted or you may need to change it, in case your credentials have changed. In such cases, you will need to remove git credentials from your local git client, and recache them. Otherwise, your git client will continue to use your old credentials during push/pull and other actions that require git authentication, and give authentication error.

Also read:

How to Add Images to on GitHub
How to Cache HTTPS Credentials for Pushing Commits
How to Change Author & Committer of Multiple Commits
How to Clone Subdirectory of Git Repository
How to Get Remote URL of Local Git Repository

2 thoughts on “How to Reset Git Credentials

Leave a Reply

Your email address will not be published. Required fields are marked *