如何将分叉项目的更改推送到原始项目?
我应该在 GitHub 上处理客户的项目,其中的更改将位于他的存储库中。我尝试遵循 fork 示例,但只能将更改转到我的帐户存储库?
在 GitHub 上的示例中,为了分叉存储库,他们创建了一个名为 upstream
的远程来指向原始项目。 从中获取更改,
get fetch upstream
git merge upstream/master
我可以通过将更改上传到我的存储库来
git push –u origin
从而将我的更改复制到我的帐户。
我尝试
git push –u upstream
将我的更改推送到原始帐户。我收到以下错误
您无法推送到 git://github.com.octocat/SpoonKnife.git 使用 [电子邮件受保护]/Spoon0-Knife.git
I’m supposed to work on my client's project on GitHub, where the changes would be on his repository. I tried to follow the fork example, but could only get the changes to go to my account repository?
In the example on GitHub, to fork a repo, they create a remote called upstream
to point to the original project. I can get the changes from it by
get fetch upstream
git merge upstream/master
I was able to upload the changes into my repo by
git push –u origin
which copied my changes to my account.
I tried
git push –u upstream
To push my changes on the original account. I got the following error
You can’t push to git://github.com.octocat/SpoonKnife.git
use [email protected]/Spoon0-Knife.git
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,为了与您的客户协作,您有两个主要选项:
拉取请求
(更多信息请参见GitHub 帮助项)。这允许您的客户在合并提案之前审查、讨论和/或请求对您的提案进行一些更改。提交者
添加到他们的项目中。这将允许您直接将提交推送到他们的存储库,而无需在您这边创建分支/克隆存储库。顺便说一句, Spoon-Knife.git 是 GitHub 的只读存储库之一(用于演示目的),并且您将无法对此做出承诺(除非您的客户是 GitHub)。因此,您的客户端的
upstream
git 远程应该指向不同的存储库以下是步骤(在将存储库分叉并克隆到本地磁盘后遵循):
git远程 rm 上游
git remote add upper git@xxxxxx
git push -u上游master
。 git push -u 将设置远程存储库的 HEAD。git pull upper upper master
如果您更喜欢名称 origin,请将上游替换为 origin,但仍按照步骤 1 删除对 Spoon-Knife.git 的引用。然后在步骤 2 中 - git remote add origin git@xxxx 。
Basically, in order to collaborate with your client, you've got two main options:
pull request
(more info on this in this GitHub help item). This allows your client to review, discuss and/or request some changes to your proposal before merging it.committer
to their project. This would allow you to directly push your commits to their repository, without the need for a fork/cloned repository on your side.As a side note, Spoon-Knife.git is one of GitHub's read-only repository (used for demonstration purpose) and you will not be able to commit to that (unless your client is GitHub). Thus, your client's
upstream
git remote should point to a different repositoryHere are the steps (to be followed after you forked and cloned the repository to your local disk):
git remote rm upstream
git remote add upstream git@xxxxxx
git push -u upstream master
.git push -u
will set the HEAD of the remote repository.git pull upstream master
If you prefer the name origin replace upstream with origin, but still follow step 1 to remove the reference to Spoon-Knife.git. Then in step 2 -
git remote add origin git@xxxx
.git://github.com.octocat/SpoonKnife.git 是一个只读 URL。正如 GitHub 建议的那样,相应的可写 URL 为 [email protected]/ Spoon0-Knife.git。
如果您希望能够推送上游存储库,您将必须要求(向上游团队,即您的客户)添加为提交者。
git://github.com.octocat/SpoonKnife.git is a read-only URL. As GitHub suggests, the corresponding write-able URL is [email protected]/Spoon0-Knife.git.
If you want to be able to push on the upstream repository, you will have to ask (to the upstream team, i.e., your customer) to be added as a committer.