是否可以使用 Visual Studio git 工具执行 Git Pull --rebase(并且可以默认设置)

Is it possible to do a Git Pull --rebase with Visual Studio git tools (and can it be set by default)

首先,正如标题所说,是否有可能在一个步骤中(即不是 fetch 然后 rebase),做一个 pull --rebase

其次,Visual Studio 中的设置强制 built-in Team Explorer git 工具始终执行 pull --rebase 而不是标准 pull (fetch/merge) .

我知道您可以使用 git config branch.autosetuprebase always 在全局或项目配置文件中设置默认值,但我想具体了解 Visual Studio 是否可以 update/change 该设置或一个类似的选项,就像大多数其他 GUI 一样。我一直找不到任何东西,所以好像没有,所以才有这个问题。

打开 Git Bash 并粘贴:

git config --global branch.autosetuprebase always

这将使每个未来 pull 成为 pull --rebase

Visual Studio 2015 不支持 pull+rebase。 您可以通过执行 'branch' 的提取手动实现它,然后对 'origin/branch'。但不是自动的。

Visual Studio 2017(候选发布版)当前将执行 pull+rebase 如果它在全局 git 设置中配置为默认选项。它目前仍然会给你一个警告说 "unexpected merge result"。我希望在最终版本出来之前能解决这个问题。

这已经是您可以真正做到的了 rebase pull

首先在你想要变基的远程上做一个获取。它不会是 "pull --rebase",但您可以转到团队资源管理器 > 分支 > 远程 >(选择您的远程)> 右键单击​​您想要 rebase onto 的分支,然后单击 rebase onto 单击变基,你基本上已经在远程分支上完成了 pull/rebase。

(但目前这是在没有 运行 a git bash 的情况下变基到远程更新的唯一方法)

在 VS2017 中,您可以使用内置功能更改 git 变基设置:转到 Team Explorer -> Home -> 设置 -> 全局设置存储库设置 -> 设置拉动时重新设置本地分支True (screenshot)