Several errors that git often encounters (failed to push some refs to, The requested returned error: 403)

1. Error: failed to push some refs to 'https://gitee.com/xxx/xxx.git' error solution.

Solution 1: Directly enter git push origin master -f to forcibly overwrite the local branch with the remote warehouse branch
Solution 2: The main reason for the error is that the README.md file in gitee (github) is not in the local code directory, so we only need to git pull --rebase origin master command README.md to pull it locally. Then execute git push origin master to submit.

二、error: unable to access ‘https://gitee.com/XXX.git/‘: The requested returned error: 403

The reason for the error is no permission to access we just need to find the account

insert image description here
Then enter the credentials, find the Credential Manager
insert image description here
insert image description here
and edit our own account.

3. When we pull the code on another computer and upload it to gitee again, we need to connect to the gitee account again

git config --global user.name “邮箱”
git config --user,email “用户名”

After the operation:

// 初始化仓库
git init
// 查看状态
git status
// 添加至本地
git add .
// 提交 
git commit -m "第一次提交"
//添加gitee地址(这里是你的项目地址 .git文件)
git remote add origin https://gitee.com/xxx
//推送代码到远程仓库
git push -u origin master

Guess you like

Origin blog.csdn.net/weixin_46824709/article/details/126123327