我可以在git中为“pull --rebase”设置一个别名吗?

问题描述 投票:7回答:3

我正在使用git使用此命令创建别名:

git config --global alias.pr=pull --rebase

但它提醒我:

error: invalid key: alias.pr=pull

我也尝试过:

git config --global alias.pr="pull --rebase"
git config --global alias.pr='pull --rebase'

但都不起作用。

什么是正确的命令?

git alias
3个回答
11
投票

不要在命令中使用equals字符,并在要为其提供别名的内容周围使用引号,例如:

git config --global alias.pr 'pull --rebase'

或者,您可以通过直接编辑.gitconfig文件来设置别名。有关设置包含参数的别名的详细信息,请参阅此link


2
投票

如果你想在做rebase时总是pull

git config --global pull.rebase true

1
投票

当您从远程分支中提取新版本时,基本上git正在进行合并然后快进。如果您想在合并步骤之前进行rebase,则必须在.git / config或home git配置文件中指定以下配置。

[branch "test-branch"]
  remote = origin
  merge = refs/heads/test-branch
  rebase = true

所以你必须在你想要的任何分支中指定rebase = true选项。

© www.soinside.com 2019 - 2024. All rights reserved.