Version control used to be something only software teams used. Now that AI tools can change dozens of files in one go, every website owner benefits from it. Git is the standard. See also AI coding assistants, which work best inside a Git repository.
Core concepts
| Term | Meaning |
|---|---|
| Repository | Your project folder plus its full history |
| Commit | A saved snapshot with a description |
| Branch | A parallel line of work |
| Remote | A copy on a server, for backup and collaboration |
| Diff | The exact lines that changed |
The basic cycle
git init # start tracking a folder (once)
git status # what changed?
git diff # show the changes
git add . # stage all changes
git commit -m "Add price list to repairs page"
git log --oneline # historyUndoing mistakes
git restore index.html # discard uncommitted changes to a file
git revert <commit-id> # undo a commit with a new commitBranches for experiments
git switch -c new-homepage # create and switch to a branch
# ... make and commit changes ...
git switch main
git merge new-homepageRemote repositories and deployment
Pushing your repository to a hosting service gives you an off-site backup and enables automatic deployment: many static hosts publish your site every time you push (see static site hosting).
What not to commit
- Passwords, API keys and
.envfiles – list them in.gitignore. - Large generated files and caches.
- Customer data and database dumps.
Frequently asked questions
Do I need Git for a small website?
Not strictly, but it is the best safety net when you or an AI assistant change files. Undoing a bad change takes seconds instead of hours.
Do I need to use the command line?
No. Code editors such as VS Code and desktop apps provide a visual interface for Git. Knowing a few commands is still useful.