Reordering commits

You can use GitHub Desktop to reorder commits in your branch's history.

About reordering a commit

Reordering allows you to alter your commit history to provide a more meaningful progression of commits. GitHub Desktop allows you to drag-and-drop commits in your branch's history to reorder them.

Reordering a commit

  1. 在 GitHub Desktop 中,单击 Current Branch(当前分支)当前分支下拉菜单
  2. In the list of branches, click the branch with the commits that you want to reorder.
  3. 单击 History(历史记录)边栏中选择的历史记录选项卡
  4. Drag the commit that you want to reorder and drop it between two adjoining commits. reorder drag and drop While the application reorders the commits, a Reorder in process dialog indicates the progress of the change.

Error messages when reordering commits

When you reorder commits, you may see one of the following notifications or error messages.

  • A notification states that the requested change to the branch will require a force push to update the remote branch. This is shown when the commits that you reordered were previously pushed to the remote branch. Force pushing alters the commit history of the branch and will affect other collaborators who are working in that branch. Select Begin reorder to start the reorder, and then click Force push origin to push your changes.

    reorder force push dialog

  • An error states that the reorder failed because there is a merge commit among the reordered commits.

    reorder merge commit dialog

  • A notification is shown indicating that there are uncommitted changes present on your current branch. Select Stash Changes and Continue to store the changes and proceed, or select Close to dismiss the message and commit the changes. When there are no longer any uncommitted changes, you can reorder your commits.

    reorder stash dialog

  • A message states that there are merge conflicts that you must resolve before the application can continue reordering commits on your branch.

    1. Click View conflicts to see the conflicts.
    2. 使用文本编辑器、命令行或其他工具(根据您的偏好)解决任何合并冲突。 更多信息请参阅“解决合并冲突”。

    reorder resolve conflicts message

此文档对您有帮助吗?隐私政策

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。