SE Fundamental

Understanding Web Version Control: A Fundamental Concept in Web Development

web development version
Table of Contents

You have probably seen a folder like this: website.html, website-final.html, website-final2.html, website-REAL-final.html. Which one is the latest? Which one works? Nobody knows, not even you.

Version control solves this problem completely. It remembers every change you ever made, lets you go back in time, and lets a whole team work on the same project without overwriting each other. In this guide you will learn how it works, see the commit tree that makes it all click, and practice with real Git commands.

What you will learn (8 minute read):

✓ What version control is, in plain English
✓ How the commit tree, branches and merges work, with a live diagram you can play with
✓ Centralized vs distributed systems
✓ Your first Git commands, with example output
✓ How to fix a merge conflict and avoid common mistakes

What Is Version Control?

Version control is a system that records every change to your project’s files over time. Think of it as a save game system for your code. You can save at any moment, jump back to an earlier save, or try something risky in a separate copy without breaking the main game.

Here is the difference in real life:

WITHOUT VERSION CONTROL
website.html
website-final.html
website-final2.html
website-REAL-final.html
website-REAL-final-USE-THIS.html
git log –oneline
e4a91c2 Fix mobile menu bug
b7d03f8 Add contact form
3c5e6a1 Improve homepage text
a1b2c3d Add homepage

Left: file names pretending to be a history. Right: a real history, with a clear message for every change.

The most popular tool today is Git. Others you may hear about are SVN (Subversion) and Mercurial. Websites like GitHub, GitLab and Bitbucket host your Git projects online so you can share them and work with others.

Why Developers Use It

1. History trackingSee who changed what, when and why, for every file in the project.
2. CollaborationMany people work on the same project at once without overwriting each other.
3. Branching and mergingBuild a new feature in a safe copy, then merge it back when it works.
4. RollbackSomething broke? Go back to the last version that worked.
5. Code reviewTeammates look at your changes and comment before they go live.
6. DocumentationCommit messages tell the story of your project and why decisions were made.
7. Automation (CI/CD)Every push can automatically run tests and deploy your site.
THE BIG IDEA

The Commit Tree

Git stores your project’s history as a tree of commits. A commit is a saved snapshot of your project, and each one points back to the commit before it, like links in a chain. When you create a branch, the chain splits into two paths. When you merge, the paths join back together.

main feature a1b2c3d4e6d7a3f3a9c219d8e7f6 9b2a8f0c7d1e4b Add homepageFix navbar bugMerge commitUpdate footer Add form stylesAdd contact form branch off merge

Time flows left to right. Blue is the main branch. Purple is a feature branch that split off, got two commits, and merged back in the filled circle.

The same tree, as Git prints it in your terminal:

Terminal
git log --oneline --graph --all
Terminal
*   f3a9c21 (HEAD -> main) Merge branch 'feature/contact-form'
|\
| * c7d1e4b (feature/contact-form) Add contact form
| * 9b2a8f0 Add form styles
* | 4e6d7a3 Fix navbar bug
|/
* a1b2c3d Add homepage

Example output. Your commit codes (hashes) will be different. The letters and numbers are each commit’s unique ID.

The words you will hear all the time

WordPlain-English meaning
Repository (repo)Your project folder plus its full history.
CommitA saved snapshot of your project, with a message describing the change.
BranchA separate line of work. You can experiment safely without touching the main code.
MergeCombining the changes from one branch into another.
HEADA pointer to where you are right now (the branch and commit you have checked out).
CloneDownloading a full copy of a repository, including its history.
Push / PullPush sends your commits to the online copy. Pull brings other people’s commits to you.
Pull request (PR)A request to merge your branch, so teammates can review it first.
ConflictWhen two people changed the same lines and Git needs you to choose.
TRY IT YOURSELF

Build Your Own Commit Tree

Play with the tree below. Add commits, create a branch, make commits on it, then merge it into main. Click a branch name to switch to it. The yellow ring shows where you are (HEAD), and the Git command for each action appears underneath.

Tip: click “Commit” a couple of times, then “New branch”.
The Git command for your last action
# Click a button above

Two Types of Version Control Systems

Version control systems come in two main designs. The difference is where the full history lives.

CENTRALIZED (CVCS) Central Server all the history Dev 1 Dev 2 Dev 3 Dev 4

One server holds the history. If it goes down, nobody can save their work. Example: SVN

DISTRIBUTED (DVCS) Remote (GitHub) Dev 1full copy + history Dev 2full copy + history Dev 3full copy + history

Everyone has the full history, so you can work offline and commit locally. Examples: Git, Mercurial

Centralized (SVN)Distributed (Git)
Where is the history?On the central serverOn every developer’s computer
Work offline?LimitedYes, commit locally anytime
Branching and mergingPossible, but heavierFast and lightweight
If the server failsWork stops until it is backAnyone’s copy can restore it
Easy to start?Simple modelA few more concepts to learn

Your First 10 Minutes with Git

Let’s go from zero to a merged feature. Install Git first, then open a terminal. The outputs below are examples, so your commit codes will differ.

STEP 1

Set up your name (one time only)

Terminal
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
STEP 2

Create a repository

Terminal
mkdir my-site
cd my-site
git init -b main
Terminal
Initialized empty Git repository in /home/you/my-site/.git/
STEP 3

Make your first commit

Create a file called index.html (anything is fine), then check what Git sees:

Terminal
git status
Terminal
On branch main

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        index.html

Git sees the file but is not tracking it yet. Add it to the “staging area”, then commit:

Terminal
git add index.html
git commit -m "Add homepage"
Terminal
[main (root-commit) a1b2c3d] Add homepage
 1 file changed, 10 insertions(+)
 create mode 100644 index.html

Why two steps (add, then commit)? The staging area lets you choose exactly which changes go into each commit. You can change five files but commit only two of them, keeping your history neat.

STEP 4

See your history

Terminal
git log --oneline
Terminal
3c5e6a1 (HEAD -> main) Improve homepage text
a1b2c3d Add homepage
STEP 5

Work safely on a branch

Let’s build a contact form without touching main. Create a branch, make some changes, and commit them:

Terminal
git switch -c feature/contact-form
# ...edit your files, then:
git add .
git commit -m "Add contact form"
Terminal
Switched to a new branch 'feature/contact-form'
[feature/contact-form 9b2a8f0] Add contact form
 1 file changed, 12 insertions(+)
STEP 6

Merge it back into main

The form works, so bring it into main:

Terminal
git switch main
git merge feature/contact-form
Terminal
Switched to branch 'main'
Updating 3c5e6a1..9b2a8f0
Fast-forward
 contact.html | 12 ++++++++++++
 1 file changed, 12 insertions(+)

“Fast-forward” means main had no new commits, so Git simply moved it forward. If both branches had new work, Git would create a merge commit instead.

STEP 7

Undo a mistake the safe way

If a commit caused a problem, git revert adds a new commit that undoes it. Your history stays intact, which is safe even on shared projects.

Terminal
git revert 9b2a8f0
Terminal
[main d4e5f6a] Revert "Add contact form"
 1 file changed, 12 deletions(-)

Careful with git reset --hard and git push --force. They can permanently throw away work, and on shared branches they can erase other people’s commits. As a beginner, prefer git revert.

STEP 8

Put it on GitHub

Create an empty repository on GitHub, then connect it and push (replace the address with your own):

Terminal
git remote add origin https://github.com/your-username/my-site.git
git push -u origin main

From now on, git push sends your new commits and git pull brings down your teammates’ work.

Code Review with Pull Requests

On a team, you do not merge straight into main. You open a pull request on GitHub, GitLab or Bitbucket. Teammates see exactly which lines changed (green is added, red is removed), leave comments, and approve it before it is merged.

github.com/your-username/my-site/pull/12● ● ●
Add contact formOpen
you wants to merge 2 commits into main from feature/contact-form
contact.html
<h1>Contact us</h1>
– <!– TODO: add form –>
+ <form action=”/send” method=”post”>
+ <input type=”email” name=”email”>
+ <button>Send</button>
+ </form>
Reviewer: Please add the required attribute to the email field.
Merge pull request

A pull request (illustration). Real screenshots of your own GitHub page work great here.

Fixing a Merge Conflict

A conflict happens when two branches changed the same line, and Git cannot decide which one to keep. It is not an error, and it is not scary. Git simply asks you to choose.

Terminal
$ git merge feature/new-title
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.

Open the file. Git marks both versions for you:

index.html
<<<<<<< HEAD
<h1>Welcome to My Site</h1>
=======
<h1>Hello and Welcome!</h1>
>>>>>>> feature/new-title
1. CHOOSEKeep the first version, the second, or write a mix of both.
2. CLEAN UPDelete the three marker lines (<<<<<<<, =======, >>>>>>>).
3. FINISHRun git add index.html, then git commit.

Good Habits for Clean Version Control

Write commit messages your future self will thank you for

AvoidBetter
updateFix mobile menu not closing on tap
fix stuffAdd email validation to contact form
finalCompress hero image to speed up homepage
asdfRemove unused CSS from the blog template

Tell Git what to ignore

Some files should never be in your history: secret keys, downloaded packages, system junk. Create a file named .gitignore in your project folder:

.gitignore
node_modules/
.env
.DS_Store
dist/
*.log

Never commit passwords or API keys. Git remembers everything, so a secret that was committed once stays in the history even after you delete the file. If it happens, change that password or key right away.

Using WordPress? You can keep your custom theme or plugin in Git. Do not commit wp-config.php (it holds your database password) or the wp-content/uploads folder. Add them to .gitignore.

Commit small and oftenOne logical change per commit makes problems easy to find and undo.
Use branchesKeep main working. Build features and fixes on their own branches.
Pull before you pushGet your teammates’ latest changes first to avoid rejected pushes.
Check before you commitRun git status and git diff so you know exactly what you are saving.
ToolTypeGood to know
GitDistributedThe industry standard. Fast, flexible, with powerful branching.
Subversion (SVN)CentralizedSimple and still found in older projects.
MercurialDistributedKnown for a clean, easy-to-use design.
Perforce (Helix Core)CentralizedBuilt for very large codebases and big files.
TFVCCentralizedMicrosoft’s older system. Most teams now choose Git.
DarcsDistributedUses a unique patch-based approach.

Where to host your Git projects

GitHubThe biggest community. Great for open source, portfolios and teams. Includes pull requests, issues and GitHub Actions.
GitLabRepositories plus built-in CI/CD. Available as a cloud service or self-hosted.
BitbucketWorks well for teams using other Atlassian tools like Jira.

Common Mistakes Beginners Make

MistakeFix
Working directly on mainCreate a branch for every feature or fix.
Committing secrets or node_modulesAdd them to .gitignore from day one.
Huge commits with vague messagesCommit small, and describe what changed and why.
“git add .” without lookingRun git status first so nothing unwanted slips in.
Push rejectedRun git pull to get others’ work, fix any conflicts, then push again.
Using force commands to fix problemsPrefer git revert. Ask for help before using --force.

Where Version Control Is Heading

The basics of Git have stayed steady for years, but the tools around it keep improving. Expect more of these:

Smarter assistanceAI tools that help write commit messages, explain changes and suggest fixes during review.
Tighter CI/CDEvery push automatically tested and deployed, with results shown right in the pull request.
Better visualsFriendlier interfaces that show history and branches as clear graphs.
Stronger securitySigned commits, secret scanning and detailed audit trails to protect your code.

Common Questions

What is the difference between Git and GitHub?

Git is the tool that tracks your changes on your own computer. GitHub is a website that hosts Git repositories online so you can share and collaborate. You can use Git without GitHub, but not GitHub without Git.

Do I need version control if I work alone?

Yes. It is your safety net. You can try bold ideas, undo mistakes and see how your project grew. Many solo developers say they would never go back.

Is Git hard to learn?

The daily basics are just a handful of commands: status, add, commit, switch, merge, push and pull. Practice them on a small project and the rest follows.

Is SVN obsolete?

Not completely. Some organizations still use it, especially for older projects. But for new projects, most teams choose Git because of its speed, flexible branching and huge ecosystem.

Can I use Git for non-code files?

Yes, Git works best with text files like code, but you can also track documents and configuration. Very large binary files (videos, big design files) are better handled with special tools such as Git LFS.

Want to go deeper? Read our next article, What do you mean by Git?, for a closer look at the tool itself.

Final Thoughts

Version control turns your project from a pile of “final_v2” files into a clear, safe history. Remember the tree: commits are snapshots, branches are safe side paths, and merges bring the good work back together.

Open a terminal, run git init on any small project, and make your first commit today. Then tell me in the comments how it went. I read every comment.

If this guide helped you, share it with a friend who is learning to code. Thank you for reading!

Share this article

Muhammad Azeem

Written by

Muhammad Azeem

Articles by Muhammad Azeem on azeemtechstudio.com.

Stay Updated

Get the latest coding tutorials, web development tips, AI tools, and technology articles delivered to your inbox.

No spam — we only use your email to send new articles.

Join the Discussion

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