What Is Git
Introduction
Git is a tool that records every change to your project files so you can go back in time, work on experiments safely, and collaborate without emailing zip files. It powers most modern software teams—from solo developers to large open-source communities. This chapter explains version control, what makes Git different, and how this tutorial fits alongside the language and DevOps tracks on Hello Code.
Prerequisites
- Basic comfort with a terminal (Command Prompt, Terminal, or bash)
- No Git installation required yet for this overview
- Helpful: you have written code in any JavaScript, Java, or Python tutorial project
The Problem Git Solves
Without version control:
project/
├── app.js
├── app_backup_march1.js
├── app_backup_march1_final.js
├── app_backup_march1_final_REAL.jsYou lose track of what changed, why, and which file is canonical. Teams overwrite each other. Rolling back a bad deploy means guesswork.
Version control gives you:
| Benefit | What it means |
|---|---|
| History | Every saved state (commit) with message and timestamp |
| Comparison | See exactly what changed between two points |
| Branches | Try features without breaking the main line |
| Collaboration | Merge work from teammates in a structured way |
| Accountability | Know who changed which lines |
Git is the most widely used version control system for new projects today.
Git in One Sentence
Git is a distributed version control system (DVCS)—every clone of a project is a full copy of the history, and most work happens locally before you sync with a remote server.
Your laptop Teammate / GitHub
┌─────────────┐ ┌─────────────┐
│ full repo │ push / pull │ full repo │
│ + history │◄─────────────►│ + history │
└─────────────┘ └─────────────┘Code explanation:
- Distributed means you commit, branch, and view history offline
- A remote (GitHub, GitLab, Gitee, company server) is the shared meeting point—not the only place history lives
Centralized vs Distributed (Concept)
| SVN (centralized) | Git (distributed) | |
|---|---|---|
| Primary copy | One server is “truth” | Every clone has full history |
| Offline commits | Limited | Full local workflow |
| Branching | Heavier | Lightweight pointers |
| Common today | Legacy enterprises | New apps, open source, startups |
Mercurial (Hg) is another DVCS—less common on new tutorials; concepts overlap with Git.
Git Is Not GitHub
| Name | What it is |
|---|---|
| Git | Free, open-source tool on your machine |
| GitHub | Hosting platform for Git repos + PRs, Issues, Actions |
| GitLab | Similar; popular for self-hosted and CI |
| Gitee | Widely used in China for hosting |
You can use Git only on your laptop with no account. You add a hosting platform when you want backup, collaboration, and CI.
Tip
Learn Git First, Platform Second
Commands like commit, branch, and merge are Git. “Star repo” and “Pull Request” are platform features built on top.
What a Commit Represents
Each commit is a snapshot of your project at one moment, identified by a hash (SHA):
commit a1b2c3d4...
Author: You <you@example.com>
Date: Thu May 28 2026
Add user login form validationCode explanation:
- Commits are immutable—you add new commits to fix mistakes, not edit old history (except advanced workflows)
- The hash lets Git deduplicate storage and refer to exact states
You will create commits in chapter 5 after install and config.
Typical Workflows Git Enables
| Scenario | Git helps you |
|---|---|
| Solo learning project | Save progress; undo bad edits |
| Team feature development | Branch per feature; merge via review |
| Open source | Fork, patch, submit Pull Request |
| Release | Tag v1.0.0; deploy that exact commit |
| CI/CD | Pipeline runs tests on every push |
Hello Code projects in Java, Node, Spring Boot, and static sites all assume files live in a Git repo eventually—often with .gitignore excluding node_modules/ or target/.
How This Tutorial Is Organized
This track follows frontend/gen_article_plan/git.md:
- Install and config — Git on Windows, macOS, Linux;
user.name,user.email - Daily commands —
status,add,commit,log,diff,.gitignore - Branches and remotes — merge, conflicts,
push,pull, Pull Requests - Safety —
restore,reset,revert,stash, when not to rewrite public history - Team practice — branching strategies, commit messages, hooks, CI
- Projects — personal repo, feature branch PR, fork upstream, releases
Examples use the command line first. VS Code and IntelliJ Git UI map to the same concepts—you will understand what the buttons do under the hood.
Warning
Do Not Commit Secrets
Never commit .env, API keys, or passwords. Git history remembers forever unless you rewrite history with expert tools. Later chapters cover .gitignore and hooks.
Git and Other Hello Code Tracks
| Track | Git connection |
|---|---|
| Linux | Terminal, SSH keys for GitHub |
| Maven / Gradle | Ignore target/, build/ |
| JavaScript / Node | Ignore node_modules/ |
| Nginx | Deploy tagged releases |
| TypeScript | Same repo as JavaScript source |
| Vue | GitHub Actions for npm run build / test in CI |
Writing code is half the job; shipping and collaborating requires Git.
Mini Preview: Commands You Will Learn
You do not run these yet—preview only:
# See repository state
git status
# Save a snapshot
git add README.md
git commit -m "Add README"
# Publish to GitHub (after remote setup)
git push origin mainCode explanation:
status— which files changedadd+commit— record a snapshot locallypush— upload commits to a remote
FAQ
Is Git only for programmers?
Mostly yes—text files diff well. Git also suits docs, config, and small binary projects; large binaries may need Git LFS (later chapter).
Do I need GitHub?
No. Git works locally. GitHub/GitLab adds hosting and collaboration when you need it.
Git vs zip backups?
Zip copies whole folders with no history, no merge, no blame. Git is built for iterative development.
How long to become productive?
Basic commit/push: a day. Comfortable branching and PRs: one to two weeks of daily use on a real project.
Is Git the same on Windows and Mac?
Same commands; path separators and line endings (CRLF vs LF) need attention—covered in install and config chapters.
What is main vs master?
Both are default branch names; new repos use main by convention. Content is the same idea.
Can I undo a bad commit?
Yes—revert, reset, or new fixing commits depending on whether history was shared. Details in a dedicated chapter.