How to create git alias for flags

I would like to create git aliases for flags passed to git. Unfortunately it does not work that way. Do you know about any alternative I could use?

eg. I want to type
git commit -m 'hello' nv
instead of
git commit -m 'hello' --no-verify

Also if possible I do not want to use variables like:
git commit -m 'hello' $(nv)

Hi @patrikturi thanks for asking here in our community!

It looks like Git will allow you to create aliases in the git config file. Git doesn’t automatically infer your command if you type it in partially.

Here’s some common examples of this:

$ git config --global checkout
$ git config --global branch
$ git config --global commit
$ git config --global status

For example after doing the above you can type git st for git status.
Read more here on git-scm docs.

I ended up doing this and quite happy with it:

git config --global 'commit --amend'
git config --global alias.amne 'commit --amend --no-edit'
git config --global alias.amnv 'commit --amend --no-verify'
git config --global alias.amnenv 'commit --amend --no-edit --no-verify'
1 Like

Excellent! Glad you were able to get this working!