1
2
3
4
You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

执行以下代码

1
git config pull.rebase false

git config pull.rebase false 作用

  1. git config pull.rebase false 的作用是设置 Git 在执行 git pull 命令时默认使用 merge 而不是 rebasegit pull 命令是将远程分支的更新合并到本地分支,如果本地分支有更新,则会自动执行合并操作

  2. 默认情况下,git pull 命令会使用 rebase 的方式来合并分支。
    使用 rebase 的好处是可以保持提交历史的线性避免了 merge 产生的分支合并记录。但是,如果在多人协作的项目中使用 rebase,可能会破坏提交历史,导致代码冲突,因此需要谨慎使用。

  3. 通过设置 git config pull.rebase falseGit 将默认使用 merge 的方式来合并分支,从而避免了 rebase 带来的潜在问题。 需要注意的是,如果在执行 git pull 命令时指定了 --rebase 选项,则 Git 会优先使用 rebase 的方式来合并分支,而不受 git config pull.rebase 的设置影响。因此,如果需要强制使用 merge 的方式来合并分支,可以在执行 git pull 命令时添加 --no-rebase 选项。