Skip to content

Instantly share code, notes, and snippets.

@bbarrows
Created November 2, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbarrows/d677d1717468163f16d7f3834a78166e to your computer and use it in GitHub Desktop.
Save bbarrows/d677d1717468163f16d7f3834a78166e to your computer and use it in GitHub Desktop.
Setting Up Git Push And Server Pull Hook
GitHookPushToServer
https://stackoverflow.com/questions/24382150/git-hook-make-server-pull-after-i-push-to-github
cd ~/example && mkdir .git && cd .git && git init --bare
cat > hooks/post-receive << EOF
> #!/bin/sh
> GIT_WORK_TREE=~/example git checkout -f
> EOF
chmod +x hooks/post-receive
git remote add server ssh://my_user@my_server.com:/absolute_path/example/.git/
git push server +master:refs/heads/master
cd ~/example && mkdir .git && cd .git && git init --bare
cat > hooks/post-receive << EOF
#!/bin/sh
GIT_WORK_TREE=~/example git checkout -f
EOF
chmod +x hooks/post-receive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment