Why version control? Git and GitHub
20 min · Beginner
Need help? Ask a tutor on WhatsApp (opens in a new tab)Showing steps for Windows. They are marked “On Windows” below.
Version control keeps one project folder plus a history of saved versions, each with a short note about what changed. Git is the version control tool almost every developer uses, and it is free.
The folder-copies problem
Version control is a system that records every saved version of a project's files, with who changed what and when, so you can see the history and go back to any earlier version.
Priya's marks project lives in five folders: marks, marks_v2, marks_final, marks_final_2 and marks_REALLY_final. A week later she cannot say which one works, or what changed between them.
Version control replaces all those copies with one folder plus a history. Each saved version in that history is a commit, and it carries a short message such as Add pass mark.
- History: every commit shows its message, author and date.
- Undo: go back to the last version that worked.
- Teamwork: friends change the same project without sending zip files on WhatsApp.
Git and GitHub
Git is a free version control tool that runs on your own computer. It saves the history of a project folder as commits, works without the internet, and is used by almost every software team.
Git keeps the whole history inside a hidden folder named .git in your project folder. A project folder that Git tracks is a repository (or repo); the next lesson makes one.
GitHub is a website that stores a copy of your repository online, so it is backed up and a team can share it. GitHub and remote repositories (opens in a new tab) connects the two.
Install Git
Install Git once. Then open a new terminal window and run git --version: any version number means Git is ready.
Official downloads
On Windows
On Windows these lessons use PowerShell (Start menu, type PowerShell, press Enter). Download the 64-bit Git for Windows Setup (.exe) using the button above, then run it.
PS C:\Users\Priya> git --versiongit version 2.45.2.windows.1
- Click Yes when Windows asks for permission.
- On Choosing the default editor used by Git, pick Use Visual Studio Code as Git's default editor (or Notepad) instead of Vim.
- On Adjusting the name of the initial branch, choose Override the default branch name and keep
main. - Keep the recommended choice on every other screen: it adds Git to PATH, sets Windows line endings and installs Git Credential Manager, which signs you in to GitHub later.
- Click Install. Close every open PowerShell window, open a new one and run
git --version.
git : The term 'git' is not recognized means this PowerShell window was open before the install. Open a new window. The installer also adds Git Bash, a second terminal; these lessons use PowerShell.Tell Git who you are
Every commit stores an author name and email, and Git refuses to commit without them. Set them once with git config --global (--global: for every repository on this computer), plus main as the first branch name, which GitHub also uses.
On Windows
Type these in PowerShell, with your own name and email. The name goes in double quotes because it has a space. The setting commands print nothing; --list shows what you saved.
PS C:\Users\Priya> git config --global user.name "Priya Sharma"PS C:\Users\Priya> git config --global user.email "priya@example.com"PS C:\Users\Priya> git config --global init.defaultBranch mainPS C:\Users\Priya> git config --global --listOutputuser.name=Priya Sharma user.email=priya@example.com init.defaultbranch=main
core.autocrlf true: Windows files end lines with CRLF, and Git stores them as LF). They live in Git's system settings, so --global --list does not show them. Leave them as they are.Example · Mistake: a name without quotes
Runs in: Your terminal
git config --global user.name Priya Sharmagit config user.namePriya
What this code does
- The terminal splits words at spaces, so Git saves only
Priya. There is no error message. - Fix: run it again with the name in double quotes,
git config --global user.name "Priya Sharma". The new value replaces the old one.
Git prints setting names in lower case, so init.defaultBranch shows as init.defaultbranch. To read one value, give the name without a value: git config user.name prints Priya Sharma.
Next step
Check your understanding
10 quick questions