Home > Net >  Automatically add flags to command
Automatically add flags to command

Time:03-25

I am a frequent user of git log -G[string], and I almost always find myself using --all and --no-textconv with it.

Can I somehow tell git to use those two options by default when calling git log -G[string]? Part of the problem is that -G expects its input with no space.

CodePudding user response:

The git alias route could look like

git config --global alias.lg '!f() { git log --no-textconv --all -G"$1"; }; f'

# then you'd do
git lg "regexp here"

CodePudding user response:

Use [alias] in the ~/.gitconfig.

[alias]
    logp = "!f() { git log -p $1; }; f"

Then git logp.

  • Related