GIT - cheat sheet
Install (Windows)
https://git-scm.com/
https://desktop.github.com/
set up new repo
Init nieuwe repo
In /srv/repo
mkdir <REPO>
git init --bare --initial-branch=main <REPO>
Set up hook script for auto deployments
In /srv/repo/<REPO>/hooks/
ln -s /srv/git/.scripts/post-receive .
Local
git remote set-url qool ssh://<user>@<server>:1611/srv/git/<project>
git push -u qool main
post-receive
The name of the git repostitory is the name of the directory in the document root.
#!/bin/bash
set -euo pipefail
#NAME="imposer"
GIT_DIR="$(git rev-parse --absolute-git-dir)"
NAME="$(basename -- "$GIT_DIR")"
TARGET="/var/www/qool/${NAME}"
BRANCH="main"
GIT_DIR="/srv/git/${NAME}"
while read -r oldrev newrev refname; do
if [ "$refname" = "refs/heads/$BRANCH" ]; then
echo "Deploying $BRANCH to $TARGET..."
git --git-dir="$GIT_DIR" --work-tree="$TARGET" checkout -f "$BRANCH"
# optional: composer install, cache clear, reload apache, etc.
# cd "$TARGET" && composer install --no-dev
# sudo systemctl reload apache2
fi
done