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:

text
project/
├── app.js
├── app_backup_march1.js
├── app_backup_march1_final.js
├── app_backup_march1_final_REAL.js

You 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:

BenefitWhat it means
HistoryEvery saved state (commit) with message and timestamp
ComparisonSee exactly what changed between two points
BranchesTry features without breaking the main line
CollaborationMerge work from teammates in a structured way
AccountabilityKnow 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.

text
  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 copyOne server is “truth”Every clone has full history
Offline commitsLimitedFull local workflow
BranchingHeavierLightweight pointers
Common todayLegacy enterprisesNew apps, open source, startups

Mercurial (Hg) is another DVCS—less common on new tutorials; concepts overlap with Git.

Git Is Not GitHub

NameWhat it is
GitFree, open-source tool on your machine
GitHubHosting platform for Git repos + PRs, Issues, Actions
GitLabSimilar; popular for self-hosted and CI
GiteeWidely 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):

text
commit a1b2c3d4...
Author: You <you@example.com>
Date:   Thu May 28 2026
 
    Add user login form validation

Code 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

ScenarioGit helps you
Solo learning projectSave progress; undo bad edits
Team feature developmentBranch per feature; merge via review
Open sourceFork, patch, submit Pull Request
ReleaseTag v1.0.0; deploy that exact commit
CI/CDPipeline 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:

  1. Install and config — Git on Windows, macOS, Linux; user.name, user.email
  2. Daily commandsstatus, add, commit, log, diff, .gitignore
  3. Branches and remotes — merge, conflicts, push, pull, Pull Requests
  4. Safetyrestore, reset, revert, stash, when not to rewrite public history
  5. Team practice — branching strategies, commit messages, hooks, CI
  6. 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

TrackGit connection
LinuxTerminal, SSH keys for GitHub
Maven / GradleIgnore target/, build/
JavaScript / NodeIgnore node_modules/
NginxDeploy tagged releases
TypeScriptSame repo as JavaScript source
VueGitHub 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:

bash
# 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 main

Code explanation:

  • status — which files changed
  • add + commit — record a snapshot locally
  • push — 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.