git 如何使用 TortoiseGit 避免合并提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16234093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:28:08  来源:igfitidea点击:

How to avoid merge commits using TortoiseGit

gittortoisegit

提问by Hareen Laks

The problem is when I'm pulland pushto the remote repository, it generates a extra commit under my name. The commit says

问题是当我拉取送到远程存储库时,它会以我的名义生成一个额外的提交。提交说

Merge branch 'master' of ssh://....

合并 ssh://... 的分支“master”

I found answers says I should use a command git pull --rebasein git bash to avoid this commit.

我发现答案说我应该在 git bash 中使用命令git pull --rebase来避免这种提交。

But I'm commonly using TortoiseGit. So how can I do it properly with TortoiseGit?

但我通常使用 TortoiseGit。那么我怎样才能用 TortoiseGit 正确地做到这一点呢?

回答by enorl76

This is an option since version 1.8 of Tortoise Git. The rebase option can be invoked from a the Fetch command:

这是自 Tortoise Git 1.8 版以来的一个选项。可以从 Fetch 命令调用 rebase 选项:

TortoiseGit fetch dialog highlighting Launch-Rebase-After-Fetch checkbox

TortoiseGit 提取对话框突出显示 Launch-Rebase-After-Fetch 复选框

回答by MrTux

Starting with TortoiseGit 2.0 you can set pull.rebaseto truein git config (e.g., by issuing git config pull.rebase true) and TortoiseGit will automatically rebase changes on top of your current branch when you pull changes (using the pull dialog or select "Fetch&Rebase" on the Sync dialog). If there is no conflict or the pulled changes fast-forward on top of your current branch, you also won't need to click on "Start rebase" and won't see the rebase dialog.

从 TortoiseGit 2.0 开始,您可以在 git config 中设置pull.rebasetrue(例如,通过发出git config pull.rebase true),当您拉取更改(使用拉取对话框或在同步对话框中选择“Fetch&Rebase”)时,TortoiseGit 将自动在当前分支的顶部重新设置更改。如果没有冲突或拉取的更改在当前分支上快进,您也不需要单击“开始变基”,也不会看到变基对话框。

Another option is already mentioned by enorl76: Enable "Launch Rebase after fetch" on fetch or pull dialog. Starting with TortoiseGit 1.8.16 you are asked whether you want to open the rebase dialog if the pulled changes fast-forward on top of your current branch or if there are no new commits.

enorl76已经提到了另一个选项:在 fetch 或 pull 对话框中启用“Launch Rebase after fetch”。从 TortoiseGit 1.8.16 开始,如果拉取的更改在当前分支上快进或没有新的提交,系统会询问您是否要打开 rebase 对话框。

TortoiseGit fetch dialog highlighting Launch-Rebase-After-Fetch checkbox

TortoiseGit 提取对话框突出显示 Launch-Rebase-After-Fetch 复选框

回答by SteckDEV

You might be able to use the Git Sync (its basically a Swiss army knife for git). It then has an option called Fetch&Rebase which is a drop down from the "Pull" item. If you switch it by default going forward it will be that option. Really cool utility I just ignored it till like 5 minutes ago. Thanks for the other answer cause it helped me find this better answer.

您也许可以使用 Git Sync(它基本上是 git 的瑞士军刀)。然后它有一个名为 Fetch&Rebase 的选项,它是“Pull”项的下拉菜单。如果您默认切换它,它将是该选项。非常酷的实用程序,直到 5 分钟前我才忽略它。感谢其他答案,因为它帮助我找到了更好的答案。