Search code examples
gitgit-push

Sending multiple options via "--push-option=" in "git push"


With Git 2.10 a new option came [--push-option=]. When a bare repository is created a post-receive.sample is auto created inside hooks directory, which saying following:

#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".

I tried following steps

  1. Renaming the file to pre-receive
  2. Clone the repository to a local machine
  3. tried git push --push-option=echoback=Hello_world

As the sample says it put back the Hello_world in my terminal.

Git Hook Manual says that i could send multiple options via --push-option= which will be available via GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... as the manual suggests.

My Question is How should i pass multiple options ? which could be passed via --push-option=

Tried options:

  1. git push --push-option="echoback=Hello echoback=World"
  2. git push --push-option="echoback=Hello;echoback=World"
  3. git push --push-option="echoback=Hello&echoback=World"
  4. git push --push-option="echoback=Hello%echoback=World"
  5. git push --push-option="echoback=Hello,echoback=World"

Solution

  • Try the following:

    git push --push-option="echoback=Hello" --push-option="echoback=World"

    This seperates the --push-options