Skip to content

Instantly share code, notes, and snippets.

@Kerrick
Created April 24, 2012 05:21
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Kerrick/2476702 to your computer and use it in GitHub Desktop.
Save Kerrick/2476702 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://user@example.com/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