This is the 8th day of my participation in Gwen Challenge.
The problem
1. When you have a Git account bound to your computer, switch to another one
1) Switch accounts
Git config -- global user.email git config -- global user.nameCopy the code
2) Install the process to submit the document at this time
Git status => git commit -m "=> git remote add origin => git pull origin Master (basically uses this sentence to report an error, Git pull Origin master -- Allow-suggested -histories. (Try changing the warehouse name when the remote repository is different from your local repository under Add) => git Push -u origin masterCopy the code
- An error is reported at this time
remote: Permission to currentAccount/currentRepo denied to previousAccount. fatal: Unable to access the ‘github.com/currentAcco… : The requested URL returned error: 403
The solution
The solution at this time
1. Set Git user name and email
Git config -- global user.name "yourname" git config -- global user.email "youremail"Copy the code
2. Generate an SSH key
Run the CD ~/. SSH command to check whether there is an SSH key: CD ~/. SSH If there is no SSH key, the folder will not exist.
Ssh-keygen -t rsa -c [email protected] Press three Press Enter. The password is empty. Your identification has been savedin /home/tekkub/.ssh/id_rsa.
Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
………………
Copy the code
Add the key to SSH: ssh-add the file name, which requires entering the password before.
Add the SSH key on Github by adding the public key in “id_rsa.pub”. Open github.com/ and add the key to your Settings
Git push is still rejected
3. View the account information
Git config-list also returns the correct information
4. Verify permissions
ssh -T [email protected]
Copy the code
You might have to say yes to generate a file that returns Hi lut! You’ve successfully authenticated, but GitHub does not provide shell access.
5. Set the remote path (SSH address) again.
git remote set-url origin [email protected]:xxx.git
Copy the code
Then GIT pushed my code on Github and found that it was still the code submitted by the original account (because the code downloaded before was used by the previous account). I modified the local code again and submitted the account on Github to show normal this time