如何将分叉项目的更改推送到原始项目?

发布于 2024-12-21 17:13:22 字数 650 浏览 1 评论 0原文

我应该在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝礼 2024-12-28 17:13:22

基本上,为了与您的客户协作,您有两个主要选项:

  • 向您的客户发送拉取请求(更多信息请参见GitHub 帮助项)。这允许您的客户在合并提案之前审查、讨论和/或请求对您的提案进行一些更改。
  • 您的客户请求将其作为提交者添加到他们的项目中。这将允许您直接将提交推送到他们的存储库,而无需在您这边创建分支/克隆存储库。

顺便说一句, Spoon-Knife.git 是 GitHub 的只读存储库之一(用于演示目的),并且您将无法对此做出承诺(除非您的客户 GitHub)。因此,您的客户端的 upstream git 远程应该指向不同的存储库

以下是步骤(在将存储库分叉并克隆到本地磁盘后遵循):

  1. 删除上游引用:git远程 rm 上游
  2. 添加您的客户端信息 - git remote add upper git@xxxxxx
  3. 推送您的更改 - git push -u上游master 。 git push -u 将设置远程存储库的 HEAD。
  4. 如果您想拉取,则相同 - 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:

  • Send your client a 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.
  • Request from your client to be added as a 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 repository

Here are the steps (to be followed after you forked and cloned the repository to your local disk):

  1. Remove the upstream reference: git remote rm upstream
  2. Add in your client's info - git remote add upstream git@xxxxxx
  3. Push your changes - git push -u upstream master . git push -u will set the HEAD of the remote repository.
  4. Same if you want to pull - 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.

粉红×色少女 2024-12-28 17:13:22

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文