Turns an empty directory on a remote server into a git push deploy target. Once set up, running git push myserver main from your local machine automatically pulls the code into the server directory and updates the working tree.
On the given SSH host:
- Creates the target directory (
mkdir -p). - Runs
git initinside it. - Uploads
create-post-update-hook.sh, executes it, and cleans up. The hook:- Writes
.git/hooks/post-update, which updates the working tree viagit reset --hard HEADafter each push and auto-stashes any dirty changes. - Sets
git config receive.denyCurrentBranch ignoreso pushes to a non-bare repo are accepted.
- Writes
Result: the remote directory behaves like a deploy-on-push git remote.
pip install fabricscp must also be available on your PATH (standard on macOS/Linux).
The target host must be defined in your SSH config (~/.ssh/config):
Host myserver
HostName example.com
User deploy
IdentityFile ~/.ssh/id_ed25519
python main.py <host> <repo_path>Examples:
python main.py myserver /var/www/myapp
python main.py staging /home/deploy/apiEach command:
- connects to the given host over SSH,
- creates the directory and initializes it as a git repo,
- installs the post-update hook.
After the script runs, inside the project you want to deploy:
git remote add myserver ssh://deploy@example.com/var/www/myapp
git push myserver mainAfter the push, the code running in /var/www/myapp on the server is updated automatically.