Web Development 3 min read

Git Basics for Web Projects

Git tracks every change to your code, lets teams collaborate safely and makes deployments repeatable. Learn the essential commands and a simple workflow for themes, plugins and web apps.

On this page

Key takeaways

  • Git tracks every change to your code, so you can undo mistakes, work in parallel and deploy safely.
  • Daily commands: git status, git add, git commit, git pull, git push, git switch -c.
  • For websites, keep themes, custom plugins and app code in Git — never wp-config.php, uploads or secrets.

If your website changes are made by editing files over FTP, one wrong save can break the site with no easy way back. Git solves that. It’s the standard tool for version control, and it’s simpler than it looks once you know a handful of commands.

Core concepts#

Term Meaning
Repository (repo) A project folder tracked by Git, with its full history
Commit A saved snapshot of changes with a message
Branch A parallel line of work (e.g. a new feature)
Merge / pull request Combining a branch back into the main line, usually after review
Remote A shared copy on GitHub, GitLab or Bitbucket

Everyday workflow#

# one-time: get the project
git clone https://github.com/you/client-theme.git
cd client-theme

# start a new piece of work
git switch -c feature/new-header

# see what changed
git status
git diff

# save a snapshot
git add header.php assets/css/main.css
git commit -m "Redesign header with dark mode toggle"

# share it
git push -u origin feature/new-header

# get others' changes
git switch main
git pull

Writing good commits#

  • Small, focused commits — one logical change each.
  • Clear messages in the imperative: “Fix mobile menu overlap”, not “changes”.
  • Commit working code; don’t commit broken states to main.

Undoing things#

Situation Command
Discard unsaved changes to a file git restore file.php
Unstage a file git restore --staged file.php
Fix the last commit message git commit --amend (before pushing)
Undo a pushed commit safely git revert <commit>
See history git log --oneline --graph

Need a hand with this?

Get a quick, honest review of your website’s SEO.

Chat on WhatsApp

What to keep out of Git (.gitignore)#

# WordPress
wp-config.php
wp-content/uploads/
wp-content/cache/
.env
node_modules/
vendor/
*.log

Never commit passwords, API keys or database dumps. Use environment variables or a secrets manager.

Git for WordPress projects#

  • Track your custom theme, child theme and custom plugins — each can be its own repo.
  • Manage third-party plugins with Composer (WPackagist) or simply exclude them.
  • Deploy with Git-based hosting, GitHub Actions, or tools like WP Pusher/DeployHQ instead of FTP.
  • Combine with a staging site: merge to a staging branch, test, then merge to main to deploy.

Branching strategy for small teams#

Keep main always deployable. Create short-lived feature branches, open a pull request, have someone review, then merge. That’s enough process for most website and SaaS teams.

Git FAQ#

Git vs GitHub?#

Git is the version control tool. GitHub (and GitLab, Bitbucket) host Git repositories online with collaboration features.

Do non-developers need Git?#

Not usually, but knowing that your site’s code is version-controlled — and where — is important for ownership and handovers.

Is there a visual Git app?#

Yes — GitHub Desktop, GitKraken, Sourcetree and VS Code’s built-in Git panel.

Found this useful? Share it

Join the discussion

Your email address will not be published. Required fields are marked *

Security code image. If you cannot read it, press refresh or contact me on WhatsApp.