Skip to content

Instantly share code, notes, and snippets.

@aqlx86
Created March 16, 2015 13:01
Show Gist options
  • Select an option

  • Save aqlx86/81abe28eae9b362c86cc to your computer and use it in GitHub Desktop.

Select an option

Save aqlx86/81abe28eae9b362c86cc to your computer and use it in GitHub Desktop.
git post-receive
# remote server domain.com
# create deploy directory
mkdir /www/app/
# create repo dir
mkdir repo.git && cd repo.git
# init git repo
git init --bare
# modify repo config
vi config
# config content
[core]
repositoryformatversion = 0
filemode = true
bare = false
worktree = /www/app
[receive]
denycurrentbranch = ignore
# create post-receive hook
vi hooks/post-receive
# hook content, change source branch
#!/bin/sh
git checkout -f <source-branch>
# chmod hook
chmod +x hooks/post-receive
# client side
git remote add staging git@domain.com:repo.git
git push staging <source-branch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment