我怎么能从原始回购的克隆推到我的分叉?
我在GitHub上创build了另一个仓库(让我们称之为orirepo )的一个fork(让我们称之为orirepo )。 后来我克隆了orirepo 。 
 git clone https://github.com/original/orirepo.git 
我修改了大约20个文件,然后我进行了修改并做了一个提交
 git add git commit 
但是,当我试图推动
 git push 
我得到这个错误:
 remote: Permission to original/orirepo.git denied to mylogin. fatal: unable to access 'https://github.com/original/orirepo.git/': The requested URL returned error: 403 
 我知道我犯了一个错误:我应该克隆我的fork而不是orirepo ,但现在已经太迟了。 我怎么能推到我的叉,而不是origin/orirepo ,我没有写访问? 
默认情况下,当您克隆存储库
-  它位于https://github.com/original/orirepo.git,
-  目前的分支叫做master,
然后
-  生成的克隆的本地configuration只列出一个远程调用的origin,它与您克隆的存储库的URL相关联;
-  克隆中的本地master分支设置为跟踪origin/master。
因此,如果你不修改你的克隆的configuration,Git解释
 git push 
如
 git push origin master:origin/master 
 换句话说, git push尝试将本地master分支推送到驻留在远程存储库(由您的克隆作为origin所知)的master分支上。 但是,您不允许这样做,因为您没有对该远程存储库的写入权限。 
你需要
- 
要么重新定义远程的 origin与您的叉相关联,通过运行git remote set-url origin https://github.com/RemiB/myrepo.git
- 
或者,如果要保留原始远程的原始定义,请定义一个与您的叉相关联的新远程(在此称为 myrepo):git remote add myrepo https://github.com/RemiB/myrepo.git那么你应该能够通过运行把你的本地 master分支推到你的fork上git push myrepo master如果你想告诉Git git push应该从现在开始推送到myrepo而不是origin,那么你应该运行git push -u myrepo master
代替。
好吧,我终于编辑了我的gitconfiguration文件:
 $ nano .git/config 
改变:
 [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = https://github.com/<origin-project>/<origin-repo>.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master 
至
 [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = https://github.com/<mylogin>/<myrepo>.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master 
然后,
 $ git push 
像魅力一样工作。
或者,感谢Thiago F Macedo的回答 :
 git remote set-url origin https://yourusername@github.com/user/repo.git 
所以,你克隆了某人的回购进行了修改,然后意识到你不能推回该回购,但你可以推到自己的分叉。 所以,你继续前进,并分出原来的回购。
您所要做的就是将本地克隆中的原始URL与分叉的repo的URL进行交换。
像这样做
 git remote set-url origin https://github.com/fork/name.git 
 其中https://github.com/fork/name.git是你原来的repo的fork的URL。 
之后,就这样
 git push 
你将能够把你的改变推到你的叉子:)
你应该首先克隆你账户中的分叉回购。
 git clone https://github.com/your_account/repo.git 
你绝对有权限推送到这个回购。 如果你想把你的代码推到原始的仓库,你可以发出一个请求。