Version Control
Version control is a system that records changes to files over time so previous versions can be reviewed, compared, and recovered.
For website development, Git is the most common version-control system.
The official Git documentation defines version control as a system for recording file changes so specific earlier versions can be recalled later. Git: About Version Control
What It Records
Version control can track changes to:
- HTML
- CSS
- JavaScript
- Templates
- Components
- Theme files
- Configuration
- Documentation
- Infrastructure code
Each recorded snapshot can contain information about:
- What changed
- When
- Who changed it
- Why it changed
Repository
A version-controlled project is typically stored in a repository.
Git repositories contain both the current files and the history of recorded changes.
Git's documentation describes cloning as receiving the repository and its history rather than only the current working files. Git: Getting a Git Repository
Version Control vs. Backup
Version Control is not a complete Backup.
It may protect source code extremely well while containing none of the site's:
- Database
- Media library
- Orders
- Form entries
- User-generated content
Both systems may be required.
Why It Matters
Version control makes changes traceable.
Instead of:
Somebody changed the CSS last month.
the project can show:
- Exact files
- Exact changes
- Commit
- Author
- Date
- Related issue or pull request
That makes maintenance and handoff much easier.
Common Problems
Common problems include:
- Production code not matching repository
- Generated or secret files committed accidentally
- Huge commits mixing unrelated changes
- Commit messages providing no context
- Repository owned by contractor
- Only one local copy of repository
- Main branch changed without review
How to Improve
Use the repository as the source of truth for website code.
Record coherent changes, keep secrets out of source control, and ensure the organization has appropriate repository ownership and access.
GitHub supports CODEOWNERS files for assigning responsibility for particular areas of a repository. GitHub Docs: About code owners