Home  >  Article  >  Development Tools  >  Let’s talk about how to delete username and password information in Git (two methods)

Let’s talk about how to delete username and password information in Git (two methods)

PHPz
PHPzOriginal
2023-04-03 11:53:032499browse

When using Git, sometimes we need to delete the saved username and password information. This situation usually occurs when the Git account password changes or when you need to switch accounts. This article will introduce how to delete username and password information saved in Git.

  1. View saved username and password information

First, we need to view the username and password information currently saved by Git. This can be achieved through the following command:

git config --global --list

The above command will display the global configuration information of Git, including our user name, email and other information. If the username and password information is not displayed here, it means that no account password information is currently saved.

  1. Delete saved username and password information

To delete saved username and password information, you can directly delete Git's credential cache. This can be achieved through the following command:

git config --global --unset credential.helper

After executing the above command, Git will no longer save any account password information.

If you want to delete specific account and password information, you can use the following command:

git config --global --unset credential.helper 'https://github.com'

The above command will delete the account and password information saved by GitHub. You need to change 'https://github.com' to the address of the Git repository you want to delete.

  1. Clear the credential cache

If just deleting the information is not enough, we also need to clear the user information stored in the credential cache. You can clear the credential cache through the following command:

git credential-manager clear

After executing the above command, confirm whether you want to clear all the credential cache and enter Y to confirm the clearing.

At this point, we have successfully deleted the username and password information saved in Git.

Summary

To delete the username and password information saved in Git, there are generally two methods: delete Git's credential cache or clear the credential cache. Users can choose different methods according to their needs.

It is worth noting that after deleting or clearing the Git credential cache, you will need to re-enter the account and password information the next time you pull or push code. At the same time, in order to avoid frequently entering passwords, we can use SSH keys to pull and push code.

The above is the detailed content of Let’s talk about how to delete username and password information in Git (two methods). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn