Created
July 11, 2012 07:03
-
-
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
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/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 |
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 | |
| # Author: Jonathan Harker <[email protected]> | |
| # push all changes, making new branches and deleting non-existent branches | |
| /full/path/to/github.sh all |
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 | |
| # 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