git pull 除了默认还有哪些模式?

What modes does git pull have other than the default?

Pro Git bookgit-pull 部分说 "In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD."

还有哪些其他模式,我在哪里可以找到它们的文档?

您链接的文档中描述了其他模式。

mode这个词没有很好的定义,所以它对不同的人有不同的含义。可能主要项目在这里隐藏得很好,大约在页面下方的 1/4 处:

-r
--rebase[=false|true|merges|preserve|interactive]

When true, rebase the current branch on top of the upstream branch after fetching. If there is a remote-tracking branch corresponding to the upstream branch and the upstream branch was rebased since last fetched, the rebase uses that information to avoid rebasing non-local changes.

When set to merges, rebase using git rebase --rebase-merges so that the local merge commits are included in the rebase (see git-rebase[1] for details).

When set to preserve, rebase with the --preserve-merges option passed to git rebase so that locally created merge commits will not be flattened.

When false, merge the current branch into the upstream branch.

When interactive, enable the interactive mode of rebase.

See pull.rebase, branch.<name>.rebase and branch.autoSetupRebase in git-config[1] if you want to make git pull always use --rebase instead of merging.

    Note
    This is a potentially dangerous mode of operation. It rewrites history, which does not bode well when you published that history already. Do not use this option unless you have read git-rebase[1]] carefully.

然而,其他 "modes" 可能包括 运行ning git pull 和参数,例如 git pull upstream branch-X。这个 运行s git fetch upstream branch-X 后面跟着 运行ning git merge FETCH_HEAD,所以对我来说这看起来是一样的 "mode".

就个人而言,我建议根本不要使用 git pull。 运行 git fetch,然后 运行 你自己的第二个命令。例如,我发现我经常想 运行 git log 两个命令之间,而使用 git pull 则不可能。在看到 git fetch 获取的内容后,我可能会选择 git merge,或 git rebase,或两者都不选。

When false, merge the current branch into the upstream branch.

警告:这是不正确的。

随着 Git 2.33(2021 年第 3 季度),“git pull --rebase=no"(man)”的文档修复。

commit d3236be (21 Jul 2021) by Felipe Contreras (felipec)
(由 Junio C Hamano -- gitster -- in commit e9fe413 合并,2021 年 8 月 2 日)

doc: pull: fix rebase=false documentation

Cc: Stephen Haberman
Signed-off-by: Felipe Contreras
[jc: updated the log message]

"git pull --rebase=false"(man) means we merge their history into ours, but it has been described the other way around.

git pull 现在包含在其 man page 中:

When false, merge the upstream branch into the current branch.

(而不是:
为false时,将当前分支合并到上游分支。)