Skip to content

Instantly share code, notes, and snippets.

@5eleven
Forked from Kerrick/gist:2476702
Created April 24, 2012 22:25
Show Gist options
  • Save 5eleven/2484313 to your computer and use it in GitHub Desktop.
Save 5eleven/2484313 to your computer and use it in GitHub Desktop.
Ready a live site for deployment via Git instead of FTP, and keep the git directory separate from the working tree on the server.
# On the server
# Assuming you the site is served from ~/www/example.com/ and you want the git directory to live in ~/git/
# Keep in mind that ^C is Control-C, or what ever the command is for your server to halt a program.
mkdir ~/git/example.com.git && cd ~/git/example.com.git
git init --bare
git config core.bare false
git config core.worktree ~/www/example.com
git config receive.denycurrentbranch ignore
cat > hooks/post-receive
#!/bin/sh
git checkout -f
^C
chmod +x hooks/post-receive
git add ~/www/example.com/*
git commit -m "Initial commit."
# On the desktop
# Assuming you want the remote to be called "live" and you want the entire project to live in ~/www/
mkdir ~/www/example.com && cd ~/www/example.com
git init
git remote add live ssh://[email protected]/home/user/git/example.com.git
git pull live master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment