如何修复GitHub拉取请求中的提交顺序(由git rebase破坏)? [英] How to fix commit order in GitHub pull requests, broken by git rebase?

查看:231
本文介绍了如何修复GitHub拉取请求中的提交顺序(由git rebase破坏)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写代码时,我将其分解为一些小的逻辑更改,这些更改很容易快速查看.

When I write code I break it into small logical changes that are easy and quick to review.

为此,我使用git rebase -i(交互式)来挤压,删除和更改提交的顺序.

To do so, I use git rebase -i (interactive) to squash, drop and change order of commits.

我注意到有时这会导致对GitHub拉取请求的提交顺序不同(尽管该顺序保留在远程分支上).

I've noticed this sometimes leads to a different order of commits on a GitHub pull request (though the order is retained on the remote branch).

例如,

  • 提交1
  • 提交2
  • 提交3

在PR中可能显示为:

  • 提交3
  • 提交1
  • 提交2

我已经在互联网上搜索过,但只能找到以下GitHub帮助页面:

I've searched the internet and only managed to find this GitHub help page: Why are my commits in the wrong order? Their answer:

如果您通过git rebase或强制推送重写了提交历史记录,则您 可能会注意到您打开一个 拉取请求.

If you rewrite your commit history via git rebase or a force push, you may notice that your commit sequence is out of order when opening a pull request.

GitHub强调了拉取请求"作为讨论的空间.所有方面 其中-评论,引用和提交-表示为 按时间顺序.重写您的Git提交历史记录同时 执行变基会更改时空连续性,这意味着 提交可能不会像您期望的那样表示 GitHub界面.

GitHub emphasizes Pull Requests as a space for discussion. All aspects of it--comments, references, and commits--are represented in a chronological order. Rewriting your Git commit history while performing rebases alters the space-time continuum, which means that commits may not be represented the way you expect them to in the GitHub interface.

如果您始终希望按顺序查看提交,建议不要使用 git rebase.但是,请放心,当您 按时间顺序查看事物!

If you always want to see commits in order, we recommend not using git rebase. However, rest assured that nothing is broken when you see things outside of a chronological order!

有没有办法解决这个问题?

Is there a way to work around this?

推荐答案

您可能不必再进行任何修复(2020年7月,三年后)

You might not have to fix anything anymore (July 2020, 3 years later)

请参阅:

现在按时间顺序对拉式请求提交进行了排序

我们正在更改拉取请求时间轴和提交视图中提交排序的方式.

We are changing the way commits are ordered in the pull request timeline and commits view.

当前按作者日期对提交进行排序,这可能会导致提交在某些情况下(例如在重新定基后)显示为乱序.

进行此更改后,提交将按照其在head分支中的时间顺序进行排序,这与Git中的顺序一致.

此排序也反映在列出有关拉取请求的提交 REST API和 PullRequest GraphQL中对象的时间轴连接.

This ordering is also reflected in the List commits on a pull request REST API and PullRequest object's timeline connection in GraphQL.

详细了解拉取请求

这篇关于如何修复GitHub拉取请求中的提交顺序(由git rebase破坏)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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