← Back to Git Course | Chapter 1: Introduction & Setup | Lesson 1 of 7

Git Introduction

Git is like a save-game system for your project: it remembers every version, so you can jump back to an earlier one or see who changed what. Lots of people can work together without erasing each other's work.

What is Git?

Git is a free, open-source distributed version control system built to handle everything from tiny scripts to massive codebases like the Linux kernel with speed and efficiency. It tracks every change made to your files over time, so a team of developers can work on the same codebase in parallel without overwriting each other's work.

Example: What is Git?

bash
git init
git add file.txt
git commit -m "Track file.txt in Git"

Why Use Version Control?

Version control lets you save numbered snapshots of your project as you go, so a bad edit is never permanent -- you can always roll back to a known-good state. Beyond safety, it's the backbone of collaboration: platforms like cookiescursor.com use it to let many contributors merge work into one shared history.

Example: Why Use Version Control?

bash
git log --oneline
git checkout <commit-hash> -- file.txt

Centralized vs. Distributed VCS

Centralized systems (like old-style SVN) require a live connection to one central server just to see history or commit. Git is distributed instead: every clone carries the entire project history locally, so you can commit, branch, and inspect logs completely offline, then sync with others whenever you have a connection.

Example: Centralized vs. Distributed VCS

bash
git clone https://github.com/user/repo.git
cd repo
git log

Key Terminology

Four terms carry most of Git's vocabulary: a Repository is the tracked project folder, a Commit is one saved snapshot with a message describing what changed, a Branch is an independent line of development you can experiment on safely, and HEAD is simply a pointer to whichever commit or branch you currently have checked out.

Example: Key Terminology

bash
git init myrepo
git commit -m "Initial commit"
git branch feature-login

Verifying Your Setup

Before creating your first repository, it's worth confirming your terminal can actually talk to Git -- running a simple version-check command verifies the executable is installed and on your system PATH, saving you a confusing error later when a real command silently fails.

Example: Verifying Your Setup

bash
git --version
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Confusing Git with GitHub, when Git is the version control tool on your computer and GitHub is a hosting service for Git repositories.
  2. Thinking Git only works with an internet connection, when it is distributed and commits, git log and branching all work offline.
  3. Treating Git as a backup of the whole disk, when it only records changes to files that you have staged and committed.
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.