7

我正在使用 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'

但两者都不起作用。

它的正确命令是什么?

4

3 回答 3

11

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

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

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

于 2013-10-25T03:19:10.673 回答
3

如果你想rebase在做的时候总是pull

git config --global pull.rebase true
于 2018-09-05T21:14:49.270 回答
1

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

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

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

于 2013-10-25T05:23:20.967 回答