Git Basics
Git Basics, Chapter 1: First repository (Free Git Course on 4wp.dev)
No change ever gets lost. You learn how Git stores changes, set it up and create your first repository: init, config, status, add,…
// tools · version control
On a WordPress project Git keeps the history of code, not of the whole site. Content lives in the database, media in uploads. Get this boundary right, and every change can be reviewed, deployed and rolled back. Shown on the real project 4wp.dev.
# hooks are switched on by Composer $ composer install # one change, one commit $ git add templates/page-git.html $ git commit -m "Git page" ✓ checks passed # staging deploys itself $ git push origin staging
// 01 — What Git is
Git is a version control system: it keeps snapshots of your files, who made them and why. A change moves through three places before it becomes history. Press the commands to move the file.
You edit files
You choose what goes into the next commit
A commit: a snapshot with a message
// 02 — What goes into Git
Plugins and WordPress core are not copied into the repository: Composer installs them by version. So the site repository stays small and every environment gets the same code.
composer.json and composer.lock.env.exampleweb/wp)vendor/ and plugins installed by Composer.env, keys, auth.json, database dumps# 4wp.dev .gitignore (shortened)
web/app/plugins/*
web/app/themes/*
!web/app/themes/4wpdev/
web/app/uploads/*
web/wp
.env
.env.*
!.env.example
/vendor
auth.json
// 03 — Branches and environments
On 4wp.dev two branches map directly to two environments. Pick one to see what happens after a push.
The Deploy staging workflow starts on every push to staging. It runs the quality gate first and deploys only if it passes.
git push origin stagingbin/checks.shcomposer install --no-devThe Deploy production workflow has no push trigger. Someone runs it by hand, and it refuses any branch except main.
mainbin/checks.shcurrent atomically// 04 — Branching model
The branching model is a separate decision from Git itself. Three common ones:
// 05 — Pre-commit hook
Our hook lives in the repository (.githooks/pre-commit) and is switched on by composer install. It runs the same script as CI, but only on staged files.
.env, keys, auth.json, SQL dumps
Private keys, GitHub tokens, cloud and API keys
php -l on every changed PHP file
composer validate: the lock file is in sync
# .githooks/pre-commit
exec bash "$(git rev-parse --show-toplevel)/bin/checks.sh" --staged
# composer.json
"hooks": "git config core.hooksPath .githooks",
"post-install-cmd": ["@hooks"]
A local hook can be skipped. That is why GitHub Actions runs the same bin/checks.sh on all tracked files before every deploy.
// 06 — Rules we work by
Passwords and keys never go into a commit. The checks block them.
Do not mix merging a pull request on GitHub with a local merge without git pull first.
Activate plugins and test the site only after a successful deploy.
// 07 — Videos
Git Basics
No change ever gets lost. You learn how Git stores changes, set it up and create your first repository: init, config, status, add,…
Git Basics
A free hands-on Git course for WordPress developers: type every command in a terminal inside the lesson, from your first commit to branches, pull requests, rebase and deploys with GitHub Actions.
Git Basics
A mistake costs a minute, not a panic. Meaningful commits, every change visible with diff and log, a .gitignore that keeps secrets local, and…
Git Basics
Several tasks in parallel, and conflicts become routine. You experiment in a branch without breaking working code, merge it, and resolve a merge…
Git Basics
Sync without "last upload wins". push, pull and fetch without losing anyone's changes, tracking branches and…
Git Basics
Code gets reviewed before it reaches main. GitHub Flow, Git Flow, pull requests and code review: you work in a team the way product studios…
Git Basics
Rebase and reflog without fear. You keep history readable with rebase, undo with reset and revert, park work with stash and cherry-pick, and bring…
Git Basics
push → checks → deploy. GitHub Actions basics, PR checks and branch protection, secrets, and deploying from main or by tag. No FTP and no manual…
// 08 — LMS4WP course · 7 modules · free
From the first commit to auto-deploy, with a terminal in every lesson where you type the commands yourself.
Every chapter has a short video. Start with the course trailer.
// 09 — FAQ
No. Composer installs it by version, like any other dependency.
We do not. The database and uploads are synced between environments separately, with a database backup before each production deploy.
No. It is the fast first check; CI repeats it where it cannot be skipped.
Git does not turn on hooks from a repository by itself. On 4wp.dev composer install runs git config core.hooksPath .githooks for you.
Yes, with git commit --no-verify. The same checks still run in GitHub Actions before any deploy.