Skip to content

Instantly share code, notes, and snippets.

@iamdionysus
Created February 25, 2014 13:27
Show Gist options
  • Save iamdionysus/9208687 to your computer and use it in GitHub Desktop.
Save iamdionysus/9208687 to your computer and use it in GitHub Desktop.
post-receive hook under /hooks in order to automate deploy on the server master branch. git push origin master invokes post-receive hook below after the push has been done. Then the code below will be executed which make repository on a server pull the change automatically.
#!/bin/sh
unset GIT_DIR
cd /my/git/project/on/server && git pull origin master
@iamdionysus
Copy link
Author

the key is unset GIT_DIR since under the hook execution, GIT_DIR will be set as the directory which is on. In higher version git, after the unset, git -C /my/git/project/on/server pull origin master should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment