1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git alias で --no-pager を使いたい

Last updated at Posted at 2018-08-29

解決方法: !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 を呼び出してるんですね。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?