Skip to content

Instantly share code, notes, and snippets.

@heaversm
Last active September 25, 2020 17:39
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 heaversm/102fb3b41d18396291275243217e0f9c to your computer and use it in GitHub Desktop.
Save heaversm/102fb3b41d18396291275243217e0f9c to your computer and use it in GitHub Desktop.
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
#source: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps
#on VPS:
cd /var/repo
mkdir [site].git && cd [site].git
git init --bare
cd hooks
cat > post-receive
#in post-receive file:
#!/bin/sh
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