git push -u origin master 失败,遇到权限被拒绝的问题

git push -u origin master failed with encounter the issue of permission denied

我在 Rstudio 中创建了新项目,并且我也打开了 github 项目存储库。但是,我打算将我所有的项目实施推送到 github 页面,但是 Git 投诉出现以下错误:

$ git push -u origin master
remote: Permission to JulaitiShayiding/mspc.git denied to julaiti.
fatal: unable to access 'https://github.com/JulaitiShayiding/mspc.git/': The requested URL returned error: 403

我使用那些 git 命令来做到这一点:

cd /path/to/my/repo
rm -rf .git
git init
git add --all
git commit -m "Initial commit"
git remote add origin "https://github.com/JulaitiShayiding/mspc.git"
$ git pull --rebase origin master
git push -u origin master
$ git pull origin master

编辑:

我尝试使用 git add .gitignore 添加 .gitignore 文件,但仍然无法解决权限被拒绝的问题。 .gitingore 文件包含以下内容:

.Rproj.user
.Rhistory
.RData

我查看了SO中的相关post,并尝试了所有git permission denied,但仍然无法解决我的问题。谁能帮我解决这个问题?如何修复这个错误?任何的想法?提前致谢:)

您似乎没有推送到存储库 https://github.com/JulaitiShayiding/mspc.git/ 的权限。要推送到存储库,您要么必须是存储库的所有者,要么必须是存储库的协作者。为此,请转到存储库设置并将您自己添加为协作者,或者要求所有者将您添加为协作者。

如果这不是您的存储库并且您找不到合作者,您可以将存储库分叉到您的帐户,进行一些更改,然后创建对原始存储库的拉取请求。然后,此拉取请求必须由存储库的所有者或合作者接受。