NAME

git-deploy - Client for push notification deployment

DESCRIPTION

git-deploy runs as a git client daemon to pull the changes from the git server instantly after a push is triggered.

SYNOPSIS

git deploy
  [ [--branch] <branch> ]
  [ { --chdir | -C } <dir> ]
  [ --umask <umask> ]
  [ -O <option> ]
  [ --build <command> ]
  [ --fix-nasty ]
  [ --background ]
  [ --max-delay <seconds> ]
  [ { --identity | -i } <identitykeyfile> ]
  [ { -v | --version } ]

--branch <branch>

If a <branch> is specified, then it will update to that branch. By default, the current branch is used.

Example: git deploy --branch main

--OR--

Example: git deploy main

--chdir <dir>

Jump to <dir> prior to running "git pull". If this option is used multiple times, then it will chdir in the order speficied. By default, the current directory is used.

Example: git deploy --chdir ~/projectx

--OR--

Example: git deploy -C ~/projectx

--umask <umask>

Set umask to <umask> in octal representation. This is useful when you need to set the umask prior to running any git commands.

Example: git deploy --umask 0022

-O <OPTION>

This -O may be used multiple times from commandline in order to pass multiple options to the server hooks. This has the same functionality as "git-client -O <OPTION>". Populates GIT_OPTION_* environment variables on server side. These ENV settings will be available to all the server side hooks, including the pre-* hooks.

--build <COMMAND>

The --build argument is any command you want to execute after any files are pulled or updated from git. By default, no command is run.

Example: git deploy --build='make -C src/.'

--fix-nasty

The --fix-nasty argument will automatically remove the offending SSH host entry for the git server from known_hosts. Only use this flag if you've changed the SSH server key on the git server host. By default, this option is disabled for better security.

Example: git deploy --fix-nasty

--background

The --background option will cause the deploy process to detach from its invoker and run in the background. This is useful when invoked from a cron since there is nobody around to see the output anyways. By default, this option is disabled so runs in the foreground.

Example: echo '7 * * * * git deploy --chdir ~/projectz --background' | crontab -

--max-delay <seconds>

The --max-delay specifies the maximum number of seconds to wait for each push notification.

If you have git-client installed, then you can run "git-client pull" to immediately release a previously deploying "git fetch" and force all pull updates without hanging your commandline for two hours waiting for the next push. By default, max-delay is 7200 seconds (or 2 hours).

If the repo is NOT run through git-server, then --max-delay specifies the interval in between each "git pull" operation in a loop. If no --max-delay is specified for this case, then the default is a random interval between 5 and 7 minutes.

Example: git deploy --max-delay 10

--identity <identity>

Specify <identity> to be used for SSH repos. If <identity> is a Private Key, it must be stored within a file, and that file should only readable by the user and should not have a passphrase. Private Key contents cannot be passed as a commandline value.

Or if SSH_AUTH_SOCK is set for Agent Forwarding, then <identity> can be the actual Public Key string (one line) or a substring or pattern or a path to a file containing the Public Key. It will be ignored if it does not match a key available by the Agent. It must match a key available by the Agent or it will be ignored.

# The easiest case is to use a Private Key File, which doesn't require Agent Forwarding:
Exmple: git deploy -i ~/.ssh/id_ed25519-repodeploy

--OR--

# Public Key File:
Example: SSH_AUTH_SOCK=~/.ssh/.agent.sock git deploy -i ~/.ssh/id_ed25519-repodeploy.pub

--OR--

# Match Comment Match
Example: git deploy -i hookbot@deployhost.local

--OR--

# Match MD5 Fingerprint
Example: git deploy -i MD5:7d:5d:fe:e7:07:51:d2:bc:a8:65:aa:17:8a:8a:50:fd
Example: git deploy -i 7d5dfee70751d2bca8

--OR--

# Match SHA256 Fingerprint or partial
Example: git deploy -i SwSJkugJviX1WXVE6L8XMR/NT3S+xAufeMOsTPH0Aac
Example: git deploy -i SwSJkugJviX

--OR--

# RegExp
Example: git deploy -i 'ssh-ed25519.*AAAA.*hookbot@'

It's possible that multiple keys available within the SSH Agent will match the substring or fingerprint or comment or RegExp specified. If so, then all will be tried in the order they appear.

HINT: To list current keys available, run "ssh-add -L". To view fingerprints, run "ssh-add -l" or "ssh-add -l -E md5".

If no --identity option is used, then the default behavior is to only use those public keys available in the agent and and any efault ~/.ssh/id_* files that ssh normally tries.

--version

Show git-deploy version.

Example: git deploy --version

INSTALL

As super user:

[root@deploy-host ~]# wget -N -P /usr/bin https://raw.githubusercontent.com/hookbot/git-server/master/git-deploy
[root@deploy-host ~]# chmod 755 /usr/bin/git-deploy
[root@deploy-host ~]#

As deploy user:

[puller@deploy-host projectz]$ git deploy --branch=main
[puller@deploy-host projectz]$ (crontab -l;echo;echo '0 * * * * git deploy --chdir ~/projectz --background </dev/null >/dev/null 2>/dev/null') | crontab -
[puller@deploy-host projectz]$

AUTHOR

Rob Brown <bbb@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2015-2026 by Rob Brown <bbb@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.