When operating git, it prompts that there is no permission.
question
I didn’t have permission when I updated the code using git pull recently.
The error content is as follows
remote: You do not have permission to pull the repository
fatal: unable to access https://gitee.com/xx/note.git/: The requested URL returned error: 403
Currently, an error is reported through https, but pulling and pushing codes through ssh are both ok.
Query information
- The default is not to cache at all. Every connection will prompt you for your username and password.
- The “cache” mode keeps credentials in memory for a certain period of time. None of the passwords are ever stored on disk, and they are purged from the cache after 15 minutes.
- The “store” mode saves the credentials to a plain-text file on disk, and they never expire. This means that until you change your password for the Git host, you won’t ever have to type in your credentials again. The downside of this approach is that your passwords are stored in cleartext in a plain file in your home directory.
- If you’re using a Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account. This method stores the credentials on disk, and they never expire, but they’re encrypted with the same system that stores HTTPS certificates and Safari auto-fills.
- If you’re using Windows, you can install a helper called “Git Credential Manager for Windows.” This is similar to the “osxkeychain” helper described above, but uses the Windows Credential Store to control sensitive information. It can be found at https://github.com/Microsoft/Git-Credential-Manager-for-Windows.
The content of the document is roughly as follows
The default is not to cache these contents. We need to enter the user name and password every time we connect.
[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-QQ3cA5dM-1589965594253)(https://zzy0-0.oss-cn-shanghai.aliyuncs.com/blog /2020-05-20-084148.png)]
- In order to facilitate us to use https to transfer code, git does not need to enter the user name and password every time, so this information will be cached.
- There are several storage methods:
- cache
- Cached mode keeps this information in memory for a period of time.
- All passwords are not stored on disk and are cleared from cache after 15 minutes.
- store
- Stored mode saves credentials to plain text files on disk and they never expire.
- You don’t have to enter this information again before we change the password for the Git host.
- But the password is
明文形式
stored in a normal file in the home directory.
- operating system
- mac
- osxkeychain
- This mode caches credentials in the secure keychain that comes with the system account. This method stores the credentials on disk and never expires, but they are encrypted using the same system that stores HTTPS certificates and Safari autofill.
- osxkeychain
- windows
- Git Credential Manager for Windows
- mac
- cache
After consulting the documentation, I found that when I used the git command, I was prompted with no permissions. It was probably because I had previously stored a password for another account, and the content I was currently accessing did not belong to this user's warehouse, so I was prompted with no permissions.
solve
Check the document document address
saw this command
git config --list --show-origin
The current command is used to view all information about git configuration, execute
git config --help
Query Impact Profile
git config --show-origin --get credential.helper
Edit configuration file
I see that the current configuration information is in /usr/local/git/etc/gitconfig
this directory, so edit this directory and delete the current line content.
Save and execute again
git pull
Information cleared successfully
Found a prompt asking me to enter user information
At this time, the original information and clearing were successful.
restore storage method
At this time it is necessary to restore theosxkeychain
Otherwise, you will need to enter your username and password every time in the future.
Excuting an order
git config --global credential.helper osxkeychain
verify
git config --list --show-origin
Successfully modified!