Essential Git commands every WordPress developer should know

Version control transforms the way WordPress projects are managed, and Git has become the universal standard for tracking code changes across the entire web development industry. Without version control, making changes to a live WordPress theme or plugin is a high-stakes guessing game: you modify a file, something breaks, and if you did not manually copy the original somewhere beforehand you have no reliable path back to a working state. Git eliminates that anxiety entirely by maintaining a complete, annotated history of every change made to every file in the project, with the ability to restore any previous state in seconds. For WordPress developers specifically, Git solves several recurring pain points simultaneously. Collaborating with another developer on the same theme becomes manageable because Git detects and merges concurrent changes to separate files automatically, and surfaces conflicts in the same file for manual review rather than silently overwriting one developer’s work with another’s. Deploying updates to a staging or production server becomes a controlled operation instead of an FTP file dump, because you can push exactly the files that changed and nothing else. Rolling back a bad plugin update or a botched functions.php edit takes a single command rather than a panicked search through file manager history. The daily Git workflow for a typical WordPress project revolves around six core commands that cover the entire cycle of making, reviewing, saving, and sharing code changes. Checking status shows you which files have been modified since the last commit. Staging files selects which changes are included in the next snapshot. Committing creates the snapshot with a descriptive message. Pulling downloads changes your collaborators pushed to the shared repository. Pushing uploads your commits to the remote. Branching creates an isolated copy of the codebase where you can develop a new feature or test a risky change without affecting the main working version. These six commands handle ninety percent of what most WordPress developers need from Git on a daily basis, and mastering them is the foundation for adding the more advanced Git workflows that platforms like SSH-based Linux server deployments rely on. The commands below assume you have Git installed and a repository initialized with git init or cloned from a remote with git clone.

Problem: Managing WordPress theme and plugin code without version control leads to risky overwrites, no rollback path, and difficult team collaboration.

Solution: Core Git commands for a standard WordPress development workflow:

# Check which files have been modified since last commit
git status

# Stage a specific file for the next commit
git add wp-content/themes/my-theme/functions.php

# Stage all changed files at once
git add .

# Commit staged changes with a descriptive message
git commit -m "Add login redirect by user role"

# Pull latest changes from the remote repository
git pull origin main

# Push your local commits to the remote
git push origin main

# Create a new feature branch and switch to it
git checkout -b feature/custom-login-redirect

# Switch back to the main branch
git checkout main

# Merge a feature branch into main
git merge feature/custom-login-redirect

# View commit history (one line per commit)
git log --oneline -10

# Discard all uncommitted changes in a file
git checkout -- wp-content/themes/my-theme/style.css

NOTE: Always include a .gitignore file in your WordPress project root to exclude the wp-config.php file (which contains database credentials), the wp-content/uploads/ directory (binary files that do not belong in version control), and any node_modules/ or build output folders. A shared wp-config.php committed to a repository is one of the most common causes of database credential exposure on GitHub. The WordPress community maintains a recommended .gitignore template at github.com/github/gitignore.