Last active
January 6, 2023 18:04
-
-
Save ceer/fac07a12f757f2a62c9a8c7def7532f3 to your computer and use it in GitHub Desktop.
deploy git branch hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
read oldrev newrev ref | |
branchname=${ref#refs/heads/} | |
GITDIR=/path/to/bare.git | |
TARGET=/path/to/files | |
git --work-tree=$TARGET --git-dir=$GITDIR checkout --force ${branchname} |
Use locally
cd project
git remote add preprod user@preprod:preprod.git
git checkout feature
git push preprod feature
git remote add live user@prod:prod.git
git checkout main
git push live
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install