更新时间:2021-12-21 04:31:02
默认情况下,当你克隆一个仓库时
By default, when you clone a repository
https://github.com/original/orirepo.git
,master
,然后
origin
的远程,它与您克隆的存储库的 URL 相关联;master
分支设置为 track origin/master
.origin
, which is associated with the URL of the repository you cloned;master
branch in your clone is set to track origin/master
.因此,如果您不修改克隆的配置,Git 会解释
Therefore, if you don't modify the config of your clone, Git interprets
git push
作为
git push origin master:origin/master
换句话说,git push
尝试将您的本地 master
分支推送到驻留在远程存储库上的 master
分支(由您的克隆为 origin
).但是,您不能这样做,因为您没有对该远程存储库的写访问权限.
In other words, git push
attempts to push your local master
branch to the master
branch that resides on the remote repository (known by your clone as origin
). However, you're not allowed to do that, because you don't have write access to that remote repository.
你需要
要么通过运行重新定义 origin
远程与您的叉相关联
git remote set-url origin https://github.com/RemiB/myrepo.git
或者,如果您想保留 origin
遥控器的原始定义,请定义一个新的遥控器(此处称为 myrepo
)与您的叉子:
or, if you want to preserve the original definition of the origin
remote, define a new remote (called myrepo
, here) that is associated to your fork:
git remote add myrepo https://github.com/RemiB/myrepo.git
然后你应该能够通过运行将你的本地 master
分支推送到你的分支
Then you should be able to push your local master
branch to your fork by running
git push myrepo master
如果你想告诉 Git 从现在开始 git push
应该推送到 myrepo
而不是 origin
,你应该运行>
And if you want to tell Git that git push
should push to myrepo
instead of origin
from now on, you should run
git push -u myrepo master
相反.