Skip to content

Instantly share code, notes, and snippets.

Last active September 25, 2020 17:39
What would you like to do?
Github Commands
#Clone and checkout a single github branch
git clone --single-branch --branch <branchname> <remote-repo>
#delete all local branches matching pattern
git branch | grep "mh/#*" | xargs git branch -D
#set up git post-receive hooks for autodeployment
#on VPS:
cd /var/repo
mkdir [site].git && cd [site].git
git init --bare
cd hooks
cat > post-receive
#in post-receive file:
git --work-tree=/var/www/[domain].com --git-dir=/var/repo/[site].git checkout -f
#write, quit
chmod +x post-receive
#on Local Machine in repo root:
git remote add live ssh://root@[domain].com/var/repo/site.git
git push live master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment