5. GIT integration

13.7.2025

Thankfully Git/GitHub is pretty seamless to set up. In a few minutes I had an account and a repository. I created a local repo on my laptop with the basics for an Apache HTML directory, and linked it all to my GitHub using Git GUI for Windows. (yes GUI, please don't judge me)

The next steps were pretty straight forward:

Well, when I refreshed the main page I was now getting a 404 error on a previously perfectly functioning local Apache index.html file. 😱

What went wrong? I spent at least two hours arguing with ChatGPT, googling online, messing with file permissions trying to understand what went wrong.

It turns out I made a simple but fatal mistake. When I created the HTML file structure on my laptop I accidentally renamed index.html to Index.html. Capitalizing the index page made Apache not properly read the main page, so it broke everything. Lesson learned: capitalization in the Linux world is extremely important.

After renaming it to index.html I was able to get it working again.

Lastly, I decided I was too lazy to type out the git and rsync commands every time I wanted to update my website. I asked ChatGPT to help me write a script that I can run to do git-pull and rsync for me. It came up with the following:

#!/bin/bash
set -euo pipefail

REPO_DIR="$HOME/repos/luke.yt"
WEBROOT="/var/www/luke.yt/public"

echo ">>> Starting deployment"

echo ">>> Updating repository..."
cd "$REPO_DIR" || { echo "Repo directory not found!"; exit 1; }
git pull origin main

echo ">>> Syncing files to webroot..."
sudo rsync -av --delete \
  --chown=www-data:www-data \
  --chmod=755 \
  --exclude .git --exclude README.md \
  "$REPO_DIR"/ "$WEBROOT"/

echo ">>> Deployment complete!"

Basically, it defines two variables, my repo directory and webroot directory, CDs into the repo, does a git pull, changes permissions to 755 and copies the changes.

Now my workflow is: update a file on my laptop, push to git, run a command on my webserver and voila!