When operating with Git, you sometimes need to enter your Git username and password. So if you forget your username and password, how can you check it? The following is an introduction to how to check your Git username and password.
In the process of using Git, the user's username and email address will be saved in the local Git configuration file. Therefore, the username and password can be obtained by viewing the configuration file.
Open Git Bash or a terminal window and enter the following command:
$ git config user.name $ git config user.email
After entering the above commands respectively, the current Git user name and email address will be returned.
If the user wants to modify the current Git user name and email address, they can use the following command:
$ git config --global user.name "NewName" $ git config --global user.email "NewEmail@xx.com"
In the above command, the user needs to modify "NewName" and "NewEmail@xx.com" Give yourself a new username and new email address.
If the user has created a token (Token) or password on Git, these passwords may have been cached locally, so they can be passed View your Git credentials to obtain your username and password.
Open Git Bash or a terminal window and enter the following command:
$ git credential-manager-core list
After entering the above command, the Git credentials currently in the cache will be returned.
If you need to delete the current cached credentials, you can use the following command:
$ git credential-manager-core erase
The above command will clear the Git credentials in the cache and require re-authentication.
Summary
So far, we have introduced two methods of viewing Git username and password, namely viewing the local Git configuration file and viewing cached Git credentials. If the user created a token or password on Git, cached Git credentials may provide a more convenient way to authenticate. However, in order to ensure the security of the account, users are advised not to save passwords and tokens. Of course, if users really need to save passwords and tokens, they also need to regularly change passwords and tokens to improve account security.
The above is the detailed content of How to check username and password on git. For more information, please follow other related articles on the PHP Chinese website!