Why Use Git?
Before learning how to use Git, it helps to understand why the entire software industry chose it. The honest answer is that Git solves five very real problems that anyone who works with text files for a living eventually runs into. Each of those problems can be solved with willpower and discipline; Git solves them with software, which scales much better.
1. The “which version is the real one?” problem
Without version control, the only way to keep older versions of a file is to make copies:
The dreaded folder
my-project/ report.docx report-v2.docx report-v2-revised.docx report-v2-revised-FINAL.docx report-v2-revised-FINAL-ok-this-one.docx report-v2-revised-FINAL-ok-this-one (Alice's edits).docx
Two months later, nobody — including the person who created them — remembers which file is current, what changed between versions, or why. Git replaces that chaos with one file plus a clean timeline you can walk through.
2. The “I broke it, can I go back?” problem
Code works. You make an improvement. Suddenly nothing works. You cannot remember exactly what you changed. Without Git the only option is to undo edits by memory — often unsuccessfully. With Git you have a complete history of every commit and can either:
git diff— see exactly which lines changed since the last working commit.git checkout HEAD -- file— discard your current changes and go back to the last committed state.git revert— create a new commit that undoes a specific past commit.git reset— move the entire branch back to an earlier point in history.git reflog— recover even after a destructive operation. Git keeps almost everything for around 90 days.
3. The “two people edited the same file” problem
Without version control, when two people edit the same file simultaneously, one of them quietly overwrites the other when they save. The losing change is gone forever, and nobody notices until somebody asks where their work went.
Git refuses to do that. When two branches change the same lines, it stops and asks a human to merge them — combining the two intentions into one. When they change different lines or different files, it merges automatically. Either way, no work is silently thrown away.
4. The “who broke this and why?” problem
Software has bugs. Sometimes the bug is in code that hasn’t been touched in two years, written by someone who left the company. Git keeps the answer to who, when, and why:
Git as an investigative tool
# Who wrote this line, and which commit? git blame path/to/file.js # Show the full context of the commit they made git show <commit-hash> # When did this bug first appear? Git will binary-search for you. git bisect start git bisect bad # current commit is broken git bisect good v1.4.0 # this old release was fine # Git checks out a commit halfway between; you test and tell it good/bad # It zeroes in on the exact commit that introduced the bug
5. The “let me try an idea” problem
Without Git you experiment cautiously, because if your experiment breaks something you have to undo it manually. With Git you create a branch — a parallel timeline — try the idea, and either keep it or throw the entire branch away. Your main work was never touched.
Experiments are cheap
# I want to try a wild refactor without risking main git switch -c crazy-refactor # ... make changes, commit them ... # Hmm, that did not work. Just go back to main. git switch main git branch -D crazy-refactor # branch gone, main untouched # Or: it worked! Bring it back into main. git switch main git merge crazy-refactor
Bonus: Git is the industry standard
Job market. Almost every software job listing mentions Git. Comfort with Git is taken for granted.
Open source. Every major open-source project lives on Git. Contributing to React, Linux, VS Code, or any other public project means using Git.
Tooling ecosystem. Every IDE, CI/CD platform, deployment service, and code-review tool understands Git. Using anything else means losing access to that ecosystem.
Code review culture. Modern code review happens on pull requests, which are a Git workflow. Knowing Git is what unlocks participation in that culture.
What Git is not
To set expectations correctly:
Not a backup tool. Git protects against accidental loss inside the repository, but a
git pushto a single remote is not a backup. A real backup is a copy on independent infrastructure.Not great for huge binary files. Git is built for text. Putting 200 MB of video into a Git repo is technically possible but painful. Use Git LFS for those.
Not a deployment system. You can deploy by pushing to a Git remote, but Git itself is not aware of staging, production, environments, or rollouts. Tools like GitHub Actions, GitLab CI, or your hosting provider fill that gap.
Not a substitute for communication. Git can show you what changed and who changed it, but it cannot replace conversations about why you should change it. Commit messages and pull request descriptions still need to be written by humans.
The five-minute payoff
You can be productive with Git after learning just five commands: init, status, add, commit, log. That is enough to get the “undo, history, and safety net” benefits described above. Everything else — branches, remotes, pull requests, rebasing — adds value on top of that foundation.