使用 SourceTree 和 git bash 在 Git 中推送选定的提交?

Push selected commits in Git using SourceTree and git bash?

假设我在 git 中进行了五次提交,例如 1 -> 2 -> 3 -> 4 -> 5。

我知道可以使用 git bash 来推送选定的提交让我们说提交 1 和 2,这在此处进行了解释 Push selective commits using git bash

但是,我想知道使用 Atlassian SourceTree 是否可行?拥有它会非常方便。

另一个问题:如何在不影响其他提交的情况下使用 git bash 仅推送提交 2 和 4?我知道这可以通过重新排序提交来完成?但是,我想知道这是否可以在不重新排序的情况下完成。

源代码树似乎不支持它 看到这个 post

首先,正如 ResidentBiscuit 所建议的,SourceTree 不支持此功能,但已为此创建了 Jira 票证。您可以跟踪 this 票以确定何时将其添加到 SourceTree 中。

同时,SourceTree 中有一个很好的功能可以和 git bash 一起解决这个问题。首先,您需要重新排序提交。点击 Repository -> Interactive Rebase。它会给你一个提交列表,你可以重新排序提交,以便 2 和 4 出现在 1、3、5 之前。然后,你可以在 git bash

中发出以下命令
$ git push origin master~3:master

此命令会将 head 设置为三个提交前并将其推送到远程 master 分支,这样只有 2 和 4 会被推送到远程 master。