将远程提交拉入我的分叉中

发布于 2024-12-22 15:36:53 字数 631 浏览 3 评论 0原文

我想将另一个人的分支中的特定提交拉到我自己的分支中。这两个项目都是我们都不拥有的同一个项目的分支。提交的人尚未向我发送拉取请求,但无论如何我都希望他在我的分支中进行更改。

我将给出一个示例场景,

  1. 开发人员 Adam 在 GitHub 上创建了一个存储库 Adam/GameLib
  2. 我,Andreas,已经为这个存储库创建了自己的分支,并在单独的 Andreas/GameLib/dev 分支上进行了一些更改。
  3. 另一位开发人员 Bob 制作了自己的分支并注意到了一个错误,进行了更改并将其作为单个提交推送到他的 Bob/GameLib/master< /代码> 分支。

Bob 没有向我(Andreas)和原始创建者(Adam)发出拉取请求。然而,我仍然想将 Bob 的单个提交从 Bob/GameLib/master 拉到我的分支 Andreas/GameLib/dev 中。

我该如何正确地做到这一点? (即,不是强力下载 Bob 的代码作为 zip 并使用文本编辑器将他的更改合并到我的分支中)

I want to pull a specific commit from another person's branch into my own branch. Both project are forks of the same project which neither of us owns. The person who made the commit has not sent a pull request to me, yet I want his changes in my branch anyway.

I'll give an example scenario,

  1. Developer Adam has created a repository Adam/GameLib on GitHub.
  2. I, Andreas, have made my own fork of this repository, and made some changes on a separate Andreas/GameLib/dev branch.
  3. Another Developer, Bob, has made his own fork and noticed a bug, making the changes and pushing it as a single commit to his Bob/GameLib/master branch.

Bob has not made a pull request to neither me (Andreas) nor the original creator (Adam). Yet, I still want to pull Bob's single commit from Bob/GameLib/master into my branch Andreas/GameLib/dev.

How would I go about doing this properly? (i.e., not brute force downloading Bob's code as a zip and merging his changes into my branch with a text editor)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

找回味觉 2024-12-29 15:36:53

您将他的存储库作为远程添加到您的存储库中,

git remote add bob git://github.com/adam...

为他的更改添加一个分支

git checkout -b patch_branch

现在,您可以获取鲍勃的更改

git fetch bob/master

,看看是否可以将其合并到您自己的 patch_branch 中

git merge bob/master

,或者您选择他的更改,您必须在其他地方查找这些更改,因为这完全取决于 oyu 想要做什么。

You add his repo as a remote to your repo

git remote add bob git://github.com/adam...

Add a branch for his changes

git checkout -b patch_branch

Now you can fetch Bob's changes

git fetch bob/master

and see if you can merge it into your own patch_branch

git merge bob/master

or you cherry pick his changes which you will have to look up elsewhere as this fully depends on what oyu are trying to do.

时光病人 2024-12-29 15:36:53
  1. 添加您想要从中提取的存储库作为远程,
  2. 从他的主控提取到您的开发分支

例如:

git remote add bob git://github.com/bob/GameLib.git
git stash // optional, to allow branch checkout
git checkout dev
git pull bob/master

就是这么简单。

  1. add the repositories you want to pull from as remotes,
  2. pull from his master to your dev branch

For example:

git remote add bob git://github.com/bob/GameLib.git
git stash // optional, to allow branch checkout
git checkout dev
git pull bob/master

It's that simple.

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