Skip to content

Instantly share code, notes, and snippets.

@ConsoleCatzirl
Created July 11, 2012 07:03
Show Gist options
  • Save ConsoleCatzirl/3088550 to your computer and use it in GitHub Desktop.
Save ConsoleCatzirl/3088550 to your computer and use it in GitHub Desktop.
A script to hook a push to github from another repo being pushed to
#!/bin/bash
# Author: Jonathan Harker <[email protected]>
REPO=GitHubUser/GitHubRepo.git
KEY="/full/path/to/github.key"
case "$1" in
# Use case 1:
# Call 'github.sh all' in post-receive hook
"all")
echo "Mirroring to github.com"
export GIT_SSH="$0"
git push --mirror [email protected]:$REPO
;;
# Use case 2:
# Call 'github.sh push' in update hook
"push")
echo "Mirroring branch to github"
export GIT_SSH="$0"
git push [email protected]:$REPO $2
;;
# Recursive call to ourselves
*)
exec ssh -i $KEY -o "StrictHostKeyChecking no" "$@"
;;
esac
exit 0
#!/bin/sh
# Author: Jonathan Harker <[email protected]>
# push all changes, making new branches and deleting non-existent branches
/full/path/to/github.sh all
#!/bin/sh
# Author: Jonathan Harker <[email protected]>
# Push to github
/full/path/to/github.sh push $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment