Skip to main content

What is Git?

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Distributed

Every developer has a complete copy of the repository history, enabling offline work and flexible workflows

Fast & Scalable

Optimized for performance with projects of any size, from small scripts to massive codebases like the Linux kernel

Branching & Merging

Lightweight branches make it easy to experiment and merge changes with powerful merge strategies

Data Integrity

Cryptographic integrity ensures your code history is tamper-proof and recoverable

Why Use Git?

Git has become the de facto standard for version control in software development. Here’s why:
1

Track Every Change

Git records the complete history of your project, allowing you to review changes, understand why code was written, and revert to previous states when needed.
2

Collaborate Seamlessly

Multiple developers can work on the same project simultaneously without conflicts, merging their work efficiently.
3

Experiment Safely

Create branches to try new features or fix bugs without affecting the main codebase. Delete them if they don’t work out.
4

Work Anywhere

With a distributed model, you have the complete repository locally. Work offline and sync when you’re ready.

Core Concepts

Repository

A Git repository is a database that stores the complete history of your project. When you run git init, Git creates a .git directory containing:
  • objects: The database storing all versions of your files
  • refs/heads: Pointers to branch tips
  • refs/tags: Named releases or milestones
  • HEAD: Pointer to your current branch

The Three States

Files in a Git repository can be in one of three states:
The actual files you’re editing on your computer. Changes here are not yet tracked by Git.
A preparation area where you assemble changes for your next commit. Use git add to stage files.
git add file.txt          # Stage a specific file
git add .                 # Stage all changes
Permanently stored snapshots in your Git database. Use git commit to save staged changes.
git commit -m "Add new feature"

Branches

Branches are lightweight, movable pointers to commits. The default branch is typically called master or main. Creating a branch is instantaneous and switching between branches is fast.
git branch feature-x      # Create a new branch
git switch feature-x      # Switch to the branch
git switch -c feature-y   # Create and switch in one command

How Git Tracks Content

Git tracks content, not files. Unlike many version control systems, Git’s add command takes a snapshot of the file’s content at that moment and stages it for the next commit. If you modify the file again, you need to run git add again to stage the new changes.
This design gives you fine-grained control over what goes into each commit, enabling you to create logical, atomic commits even when you’ve made multiple unrelated changes.

Git’s History

Git was originally written by Linus Torvalds in 2005 for Linux kernel development, with help from a group of hackers around the net. The name “git” was chosen as:
  • A random three-letter combination that’s pronounceable and not used by common UNIX commands
  • British slang meaning “stupid, contemptible and despicable”
  • Global Information Tracker (when it works well)
  • Goddamn Idiotic Truckload of sh*t (when it breaks)
Git is an Open Source project covered by the GNU General Public License version 2 (GPLv2). You can contribute to Git development by joining the mailing list at git@vger.kernel.org.

Getting Help

Git has extensive built-in documentation. You can access help for any command in two ways:
# View documentation for any command
man git-log
man git-commit
man gittutorial
You can also use git help -a to see all available commands, or visit the official documentation at https://git-scm.com/.

Next Steps

Ready to start using Git? Continue to the next sections:

Installation

Install Git on your system

Quick Start

Make your first commit in 5 minutes

Tutorial

Complete guided tutorial with real examples

Commands

Browse all Git commands

Community Resources

For security-relevant issues, please disclose them privately to the Git Security mailing list at git-security@googlegroups.com before making them public.