【问题标题】:Make a new Pull Request on the same branch where the last commit hasn't been merged yet在最后一次提交尚未合并的同一分支上发出新的拉取请求
【发布时间】:2019-09-17 10:33:27
【问题描述】:

好的……情况是这样的:

  • 我创建了一个仓库
  • 我创建了一个新分支。分支名称是configs
  • 我提交了一些更改并提出了拉取请求 #1
  • 拉取请求 #1 仍在审核中,尚未合并到基础存储库中
  • 我又做了一些更改。仍在configs 分支中。但是这个新的变化不会影响之前的变化(不同的文件)
  • 我做了一个新的提交,当然它还在configs brach
  • 当我查看 github 时,这个新的提交会转到之前的 pull request,pull request #1。

好吧,我的问题是 “你如何将这个新的提交作为一个新的拉取请求,或者说拉取请求 #2 但仍然在同一个分支中?”

谢谢。

【问题讨论】:

标签: git github pull-request


【解决方案1】:

将您的第二次提交放在另一个分支上

# now

A---B---C <<< main-line
         \
          D---E <<< configs

# target

A---B---C <<< main-line
         \
          D <<< configs
           \
            E <<< configs-plus

要做到这一点,一步一步来:

# start from branch configs
git checkout configs

# Create the new branch (by default, it'll point at HEAD, so configs)
git branch configs-plus

# reset current branch (still configs) to last commit
git reset --hard @^

# finally, push (--force (or -f) needed because history has been rewritten)
git push -f origin HEAD

然后创建一个新的 PR configs-plus &gt; main-line。第一个 PR 将被强制推送更新以删除第二个提交。

【讨论】:

  • 感谢它有效!我们还可以使用 git stash 和 git stash pop 对新分支进行任何工作更改。
猜你喜欢
  • 2012-08-31
  • 2021-07-11
  • 2021-08-15
  • 2020-04-15
  • 2022-07-01
  • 2013-11-27
  • 2013-02-02
  • 2017-06-19
  • 2019-09-26
相关资源
最近更新 更多