Unit 1 · Introduction to Version Control
Why every developer uses version control
Learn the problem version control solves, the three kinds of VCS, how Git and GitHub differ, and set up Git on Windows with your own GitHub account.
The Amroli Canteen problem
Meet four BCA final-year students at SBCCAS. For their project they are building Amroli Canteen, a web app that lets students order samosas and chai before the lunch break, so nobody waits in the queue.
| Student | Builds |
|---|---|
| Krish | the menu and cart pages |
| Dhruvi | the order system in Python |
| Meet | the database |
| Hetvi | team lead: plans, reviews and writes the README |
In the first two weeks they share code the way many students do: WhatsApp, pen drives and email. Here is what happened.
Tap a card to see how Git fixes it.
Hetvi, the team lead, says: "Professional teams don't work like this. They use Git and GitHub. Let's learn it properly." That is exactly what you will do in this course.
What is version control?
A version control system (VCS) is software that records changes to files over time, so you can see who changed what and bring back any earlier version.
A time machine for your project
Think of a video game that saves your progress at every checkpoint. If you fall into lava, you restart from the last checkpoint instead of from the beginning. A VCS gives your code the same superpower, and each checkpoint is called a commit.
A VCS answers four questions about every change:
- What changed? (exactly which lines)
- Who changed it?
- When was it changed?
- Why? (the message the author wrote)
Three kinds of version control
Version control has grown up in three stages.
Local VCS
History lives on one machine. If its disk fails, history is gone.
Centralized VCS
Everyone works through one server. Server down = nobody can commit.
Distributed VCS Git
Every computer has the full history. Work offline; any copy can restore the others.
1. Local VCS. Versions are kept in a small database on one computer. An early example is RCS (1982). Like a personal diary in your room: useful, but only you can read it, and if the house floods it is gone.
2. Centralized VCS. One central server holds all versions. Developers check out files from it and send changes back. Examples: CVS and Subversion (SVN). Like one library book the whole class must share: if the library is closed, nobody can study. The server is a single point of failure.
3. Distributed VCS. Every developer has a complete copy of the project and its whole history on their own computer. Examples: Git and Mercurial. Like every student owning a full photocopy of the book: if one copy is lost, any other copy can replace it.
| Local | Centralized | Distributed (Git) | |
|---|---|---|---|
| Where history lives | One computer | One server | Every computer |
| Work offline? | Yes | No | Yes |
| Team work | No | Yes | Yes |
| If one machine dies | History lost | Everyone stuck | Nothing lost |
Why Git won
Git was created in 2005 by Linus Torvalds, who also created Linux, to manage the Linux kernel's thousands of contributors. It is fast, works offline and makes branching cheap. Today almost every software company uses it.
Benefits of Git and GitHub
Git a tool
- Tracks every change in a folder
- Works offline
- Free, open source (2005, Linus Torvalds)
- Commands:
init,add,commit,log…
GitHub a website
- Stores Git repositories online
- Needs the internet
- Adds teamwork: issues, pull requests, forks
- Your public developer portfolio
Git works without GitHub. GitHub needs Git. Similar sites: GitLab, Bitbucket.
Git is the tool on your computer. GitHub is a website that hosts Git repositories so a team can share them. Together they give you:
- Complete history: every change, with who, when and why.
- Safe experiments: try an idea on a branch without breaking working code (Unit 3).
- Teamwork: many people work on the same project at the same time.
- Undo: go back to any earlier version in seconds (Unit 4).
- Backup: your code is safe on GitHub even if your laptop is not.
- Career: your GitHub profile is a portfolio that recruiters look at.
Git ≠ GitHub
A common exam mistake is writing "GitHub is a version control system". Git is the version control system. GitHub is a hosting service built around Git. GitLab and Bitbucket are similar services.
Installing Git on Windows
The SBCCAS labs use Windows, so here is the Windows installer step by step. (On macOS, Git comes with the Xcode tools; on Ubuntu, run sudo apt install git.)
- Open git-scm.com and click Download for Windows. Choose the 64-bit installer.
- Run the installer and click Next on the licence screen.
- Select Components: keep the defaults.
- Choosing the default editor: change Vim to Notepad or Visual Studio Code. (Vim confuses beginners. If it ever opens, type
:wqand press Enter to leave.) - Adjusting the name of the initial branch: choose Override the default branch name and type
main. GitHub usesmaintoo. - Adjusting your PATH: keep Git from the command line and also from 3rd-party software (recommended).
- SSH executable: keep Use bundled OpenSSH.
- HTTPS transport backend: keep Use the OpenSSL library. (If the college network blocks GitHub, your lab admin may choose Windows Secure Channel.)
- Line ending conversions: keep Checkout Windows-style, commit Unix-style line endings.
- Terminal emulator: keep Use MinTTY.
- Default behaviour of
git pull: keep Fast-forward or merge. - Credential helper: keep Git Credential Manager. It opens a browser window to sign in to GitHub.
- Keep the remaining defaults and click Install, then Finish.
Now open Git Bash from the Start menu and check the installation:
$ git --versiongit version 2.47.1.windows.1
Your number may be newer. Any version 2.x is fine.
No laptop? No problem.
Everything in Units 1–4 can also be practised in this site's Playground, which runs real Git inside your browser, even on a phone.
Telling Git who you are: git config
Every commit records an author name and email. Before your first commit, tell Git who you are. You only need to do this once per computer:
$ git config --global user.name "Krish Patel"$ git config --global user.email "krish@example.com"
Check your settings:
$ git config --listinit.defaultbranch=mainuser.name=Krish Pateluser.email=krish@example.com$ git config user.nameKrish Patel
| Option | Where the setting is saved | Applies to |
|---|---|---|
--global | ~/.gitconfig in your home folder | every repository for your user account |
| (no option, inside a repository) | .git/config | only this repository |
Use the same email as GitHub
Use the email address you will use for your GitHub account. GitHub uses it to link your commits to your profile and to show the green squares on your contribution graph.
Shared lab computers
On a shared lab PC, set your name without --global inside your own project folder, so the next student's commits are not labelled with your name.
If you forget to configure Git, your first commit stops with this message. Now you know how to fix it:
Author identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name"
Getting help: git help
Git has its own manual built in. There are three ways to ask it for help:
| Command | What you get |
|---|---|
git help | the list of the most common Git commands |
git help <command> | the full manual page for one command, e.g. git help commit |
git <command> -h | a short summary of options, right in the terminal |
$ git commit -husage: git commit [-a] [-m <msg>] [--amend] [--allow-empty] -m <msg> use the given message -a, --all stage modified and deleted tracked files first --amend replace the last commit
Read the error messages
Git's messages are unusually helpful. They often tell you the exact command to run next. Before searching the internet, read what Git printed.
Creating your GitHub account
- Go to github.com and click Sign up.
- Enter your email, the same one you used in
git config. - Create a strong password.
- Choose a professional username:
krish-patelorkrishpatel-dev, notcoolboy007. It becomes your portfolio address:github.com/krish-patel. - Solve the puzzle, then type the code GitHub emails you.
- Choose the Free plan.
- Turn on two-factor authentication (2FA): Settings → Password and authentication → Enable two-factor authentication. Use an authenticator app or the GitHub Mobile app, and save your recovery codes somewhere safe. GitHub requires 2FA for everyone who contributes code.
- Add a profile photo, your name, and "BCA student at SBCCAS, Surat" in your bio.
Lab L-01: your profile README
Create a repository named exactly the same as your username (for example krish-patel/krish-patel) and tick Add a README file. Whatever you write in that README appears on your GitHub profile page, like a business card. The full steps are on the Labs page.
Unit 1 summary
- A version control system records every change: what, who, when and why.
- Local VCS keeps history on one machine; centralized VCS on one server; distributed VCS (Git) on every computer.
- Git is the tool on your computer; GitHub is the website that hosts repositories for teams.
- On Windows, install Git for Windows, and set the default branch to
mainand the editor to Notepad or VS Code. git config --global user.nameanduser.emailtell Git who you are.git help,git help <command>andgit <command> -hare your built-in manual.- Create a GitHub account with a professional username and turn on 2FA.
Next, practise with Missions M-01 and M-02 below, then take the Unit 1 quiz.
Missions & labs
Practise in real Git: each mission runs in your browser and checks your work.