Prepare server
- Use SSH to get to webspace:
ssh user@webspace.host
- Navigate to correct directory:
cd myapp/production
- Create Git folder:
mkdir .git
- Navigate to the folder:
cd .git
- Init bare repository:
git init --bare
- Create file called "post-receive" in
.git/hooks
with this content:
#!/bin/sh
The production directory
TARGET="/kunden/homepages/xx/xxx/htdocs/myapp/production/app"
The Git repo
REPO="/kunden/homepages/xx/xxx/htdocs/myapp/production/.git"
Deploy the content to the directory
git --work-tree=$TARGET --git-dir=$REPO checkout -f
Update: It's important that your "post-receive" file has the permission to execute. In my case, I gave the file permission 705.
Prepare local development setup
- Project folder has to be a Git repository. If it isn't already, run:
git init
- Add remote:
git remote add deploy ssh://user@webspace.host/kunden/homepages/xx/xxx/htdocs/myapp/production/.git
Upload changes
- Commit local changes.
- Run this to upload them:
git push deploy HEAD