从派生创建新的拉取请求,而无需提交前一个派生 [英] Create new pull request from fork without having commits of the previous fork

查看:82
本文介绍了从派生创建新的拉取请求,而无需提交前一个派生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我已经对其他人的仓库进行了一些提交,然后提交了相同请求的拉取请求.我以前的拉取请求尚未合并,现在我需要提交一个没有先前提交的新拉取请求,但是要对fork进行新的更改(我需要我的旧拉取请求及其提交留下来).我该怎么办?

So i've made a few commits to my fork of someone else's repo, and then submitted a pull request for the same. My old pull request hasn't been merged yet, and now i need to submit a new pull request without the previous commits, but with new changes that i'm going to make to my fork (i need my old pull request with its commits to stay, too). How can i do this?

推荐答案

要真正理解这一点,我们需要定义一些东西.

To really understand this, we need to define some things.

首先,这里有一个问题,因为拉取请求"本身并不是Git的东西.您已包含标签和GitHub 确实定义拉取请求"-实际上,他们至少重新定义了一次;请参阅 VonC于2013年初提交的答案,此后对此进行了多次修订,但并非每个人都使用完全相同的定义(不仅仅是有趣的定义在其中的Fox Business图片中,在确切细节上存在真正的分歧,并且正如刚刚指出的那样,即使GitHub本身也不同意.但是它们都有一些共同的特征.一般的想法是至少涉及两个人:您自己和其他人. 您的目标是让其他人"将您的工作并入他们的工作中.为此,您想使其成为对他们来说尽可能简单.

First, there's a bit of a problem here because "pull request" is not a Git thing itself. You have included the tag and GitHub does define "pull request"—in fact, they've re-defined it at least once; see this early 2013 answer from VonC, revised numerous times afterward—but not everyone uses the exact same definitions (not just the amusing Fox Business image therein, there's real disagreement on the exact details, and as just noted, even GitHub itself does not agree with itself). But they all share some common features. The general idea is that there are at least two humans involved: yourself, and someone else. Your goal is to get the Someone Else to incorporate your work into their work. To that end, you want to make it as easy as possible for them.

接下来,还有另一个问题,因为叉子"本身也是 而不是Git事物. SO问题 git叉实际上是git克隆吗?正确地指出了这一点:

Next, there's another problem because "fork" is also not a Git thing itself. The SO question Are git forks actually git clones? states this correctly:

我不断听到人们说他们在用git分叉代码. Git"fork"听起来像git"clone",加上一些(毫无意义的)放弃未来合并的心理意愿. git中没有fork命令,对吧?

I keep hearing people say they're forking code in git. Git "fork" sounds suspiciously like git "clone" plus some (meaningless) psychological willingness to forgo future merges. There is no fork command in git, right?

Github通过在其上装订对应关系使分叉更加真实.也就是说,您按下派生按钮,然后再按下拉取请求按钮时,系统足够智能,可以向所有者发送电子邮件.因此,这与回购所有权和权限有关.

Github makes forks a little more real by stapling correspondence onto it. That is, you press the fork button and later, when you press the pull request button, the system is smart enough to email the owner. Hence, it's a little bit of a dance around repo ownership and permissions.

(VonC再次给出了一个很好的答案:是的,"fork" 一个克隆,但在GitHub服务器端完成,具有这些额外的属性,权限等).使用此服务器端克隆,也使使用GitHub的人更容易取回您的工作. 但是,最后,大概是git merge了,因为GitHub在幕后使用了git merge(有时是--squash).它可能只有一些Web GUI clicky按钮,这使它变得更容易

(and once again VonC has a nice answer: yes, "fork" is a clone, but done on the GitHub server side, with those extra attributes, permissions, and so on). Using this server-side clone makes it easier for someone who is also using GitHub to take back your work. In the end, though, it's probably about git merge, since GitHub uses git merge (sometimes with --squash) under the covers. It just might have some web GUI clicky buttons that make it easier.

因此,我已经对其他人的仓库进行了一些提交,然后提交了相同请求的拉取请求.我以前的拉取请求尚未合并,现在我需要提交一个没有先前提交的新拉取请求,但是要对fork进行新的更改(我需要我的旧拉取请求及其提交留下来).我该怎么办?

So i've made a few commits to my fork of someone else's repo, and then submitted a pull request for the same. My old pull request hasn't been merged yet, and now i need to submit a new pull request without the previous commits, but with new changes that i'm going to make to my fork (i need my old pull request with its commits to stay, too). How can i do this?

其中一些取决于其他人".但是:

Some of this depends on the "someone else". But:

  • 如果您将每个拉取请求(请结合这项工作")隔离到您自己的分支中;和
  • 如果您准备好将其分支提示与分支提示合并,以便他们可以轻松地git merge合并它,也许只需单击一个按钮即可.
  • if you isolate each pull request ("please incorporate this work") to a branch of your own; and
  • if you have that branch-tip ready to merge with their branch-tip, so that they can easily git merge it, perhaps with a clicky button

那么,对于他们来说,您无疑已尽可能地轻松了.

then you have certainly made it as easy as you possibly can, for them.

是否以及多少您的fork"(我们的意思是您在GitHub上维护的克隆")的实质取决于他们将如何获取您的提交和合并(或决定是否合并).但是,将每个提交集放在其自己的分支上,同时在您的fork中保留一些分支(通常但并非总是命名为master),并在其中保留一些可能具有相同名称的分支fork,即它们在GitHub上维护的克隆,应具有预期的效果.

Whether and how much "your fork"—by which we mean "your clone as maintained on GitHub"—matters depends on exactly how they are going to obtain your commits and merge (or decide whether to merge). But, putting each set of commits on its own branch, while keeping some branch—often but not always named master—in your fork up to date with some, probably same-named, branch in their fork, i.e., their clone as maintained on GitHub—should have the desired effect.

完成所有这些操作意味着您的提交可以轻松添加到存储库中.此外,当他们使用clicky按钮(如果这是他们的计划和方法)时,您的提交将以某种方式复制到其存储库中(如果是常规合并,则是直接复制加合并提交;如果压榨,则被压缩为一个新的en-masse提交.合并").完成后,部分上的最小工作量也将更新您的分叉,以说明他们对您工作的整合.

Doing all of this means that your commits become something they can easily add to their repository. Moreover, when they use the clicky buttons—if that's their plan and their method—your commits will be copied into their repository in some fashion (straight copy plus merge commit, if regular merge; squashed into one new en-masse commit if squash "merge"). Once that's done, it will also be a minimal amount of work on your part to update your fork to account for their incorporation of your work.

(免责声明:我不使用GitHub上的clicky按钮.:-)我只是将提交的内容直接加载到我的计算机上的存储库中,在这里我可以使用命令行界面进行完全控制.)

(Disclaimer: I don't use the clicky buttons on GitHub. :-) I just load your commits into my repository directly, on my machines, where I have full control using the command-line interface.)

这篇关于从派生创建新的拉取请求,而无需提交前一个派生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆