Last active
August 29, 2015 14:09
-
-
Save qutek/01eae7b7f45c5673755d to your computer and use it in GitHub Desktop.
[Git] Automatic Deployment with git hooks
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
| /** | |
| * Create directory and init as --bare repo | |
| */ | |
| mkdir repo && cd repo | |
| mkdir site.git && cd site.git | |
| git init --bare | |
| /** | |
| * Goto /hooks/ and create post-receive file with the following script | |
| * @work-tree : your public_html location | |
| * @git-dir : your git directory | |
| */ | |
| #!/bin/sh | |
| git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f | |
| /** | |
| * Change file permision so that can be excuted | |
| */ | |
| chmod +x post-receive | |
| /** | |
| * Add remote on local git ponted to your server git | |
| */ | |
| git remote add production ssh://user@mydomain.com/var/repo/site.git | |
| /** | |
| * For cpanel server, please add this line on .git/config | |
| * Example: | |
| * | |
| * url = user@mydomain.com/var/repo/site.git | |
| * fetch = +refs/heads/*:refs/remotes/upstream/* | |
| * receivepack = /usr/local/cpanel/3rdparty/bin/git-receive-pack | |
| */ | |
| receivepack = /usr/local/cpanel/3rdparty/bin/git-receive-pack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment