解決方法: !git
を使う
だめ.gitconfig
[alias]
b = --no-pager branch
$ git b
fatal: alias 'b' changes environment variables.
You can use '!git' in the alias to do this
怒られた。 !git
を使えという
正解.gitconfig
[alias]
b = !git --no-pager branch
$ git b
release
* master
便利ですね。
As you can tell, Git simply replaces the new command with whatever you alias it for. However, maybe you want to run an external command, rather than a Git subcommand. In that case, you start the command with a ! character. This is useful if you write your own tools that work with a Git repository.
2.7 Git Basics - Git Aliases より引用
git alias の定義は !
を先頭におくことで外部コマンドを使える。外部コマンドとして git を呼び出してるんですね。