Search code examples
gitgerritgit-pushgit-config

Can I set push-options (git push -o "...") in git config?


Git 2.10 introduced git push options (git push -o "my string").

Many command line options are configurable, and I was wondering if it was possible for this too. I was not able to find it in git-config, but perhaps I'm overlooking it.

So, would it be possible to add a (set of) default push option(s), to have ...

git push -o "r=joh.doe"

... the default when running ...

git push

?

Context: I am using this with Gerrit to directly assign changes to reviewers (documentation for reference - using compatible syntax <push-ref>%my_string). When uploading many changes and working in pairs to review each other's code it would be useful if I can add that person as reviewer at push-time already.


Solution

  • This has become configurable in Git 2.16 (quoting release notes).

    The "--push-option=" option to "git push" now defaults to a list of strings configured via push.pushOption variable.

    So, when applied to Gerrit as for my use case, this should work to add reviewer to john.doe and publish draft comments on push time by default.

    git config --add push.pushOption r=john.doe
    git config --add push.pushOption publish-comments