Skip to content

Instantly share code, notes, and snippets.

@liamcurry
Created August 23, 2012 06:49
Show Gist options
  • Save liamcurry/3433559 to your computer and use it in GitHub Desktop.
Save liamcurry/3433559 to your computer and use it in GitHub Desktop.
Setting up deployment via git

Setting up deployment via git

Add this entry to your local .git/config:

[remote "prod"]
  url = amazon:/path/to/repo.git
  fetch = +refs/heads/*:refs/remotes/amazon/*

For this example, you should have "amazon" as an entry in your ~/.ssh/hosts file, like so:

Host amazon
  Hostname <Actual host name of the server>
  User <User to login as>
  IdentityFile ~/.ssh/amazon-private-key

Then on the server:

mkdir -p /path/to/repo.git
cd /path/to/repo.git
git init --bare
git --bare update-server-info
git config core.bare false
git config core.worktree /path/to/actual/worktree
git config receive.denycurrentbranch ignore
cat > hooks/post-receive << EOF
#!/bin/sh
git checkout -f
EOF
chmod +x hooks/post-receive

You should then be able to do a git push prod master from your local copy.

Additional resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment