GitGit Glossary

Git Glossary

Over 60 Git terms defined clearly, with examples. Use this as a reference when documentation or a colleague uses terminology you are not familiar with.

Core Objects and Storage

Term

Definition

Example

Repository (repo)

A directory that Git manages. Contains all versions of all files, the full commit history, branches, and tags. Stored in the hidden .git folder.

git init creates a new repository in the current directory.

Commit

A snapshot of the entire repository at a specific point in time. Identified by a unique SHA-1 hash. Contains the author, date, message, and a pointer to the root tree object.

git commit -m "Add login page" creates a commit.

Tree object

An internal Git object representing a directory. Contains pointers to blob objects (files) and other tree objects (subdirectories).

The root tree of a commit represents the top-level directory.

Blob object

An internal Git object storing the raw content of a file — with no filename. The filename is stored in the tree that points to the blob.

git cat-file -p HEAD:src/app.ts shows a blob's content.

Tag object

An annotated tag is a full Git object with tagger name, date, and message. A lightweight tag is just a named pointer to a commit.

git tag -a v1.0.0 -m "First release" creates a tag object.

Ref

A human-readable name (pointer) to a commit SHA. All branches and tags are refs.

refs/heads/main, refs/tags/v1.0.0

Refspec

A pattern that maps remote refs to local refs. Used by fetch/push to know which refs to transfer.

+refs/heads/*:refs/remotes/origin/*

Packfile

A compressed file storing many Git objects efficiently using delta compression. Reduces repository size dramatically compared to storing loose objects.

Visible in .git/objects/pack/*.pack

Object database

The content-addressable store in .git/objects/ where all Git data lives (blobs, trees, commits, tags).

Every object is stored at a path derived from its SHA-1 hash.

Working Areas

Term

Definition

Example

Working tree

The directory you see and edit files in — the current checkout of a specific version of the project.

When you edit src/app.ts, you are modifying the working tree.

Index

Another name for the staging area. A binary file .git/index that records what will go into the next commit.

git ls-files --stage shows the raw index contents.

Staging area

The intermediate area between the working tree and the repository. Files added with git add move here. The commit is made from the staging area, not directly from the working tree.

git add src/app.ts adds the file to the staging area.

Stash

A stack of saved dirty working tree states. Lets you set aside uncommitted changes temporarily without committing them.

git stash saves changes; git stash pop restores them.

Worktree

A linked working directory that shares the same .git directory but checks out a different branch. Created by git worktree add.

git worktree add ../hotfix-tree hotfix/123

Branches and Refs

Term

Definition

Example

Branch

A lightweight, movable pointer to a commit. When you commit on a branch, the pointer automatically advances to the new commit.

main, feature/login, hotfix/null-pointer

HEAD

A special ref pointing to the current commit (what is checked out). Usually points to a branch; when it points directly to a commit, you are in detached HEAD state.

cat .git/HEAD shows ref: refs/heads/main

Detached HEAD

State where HEAD points directly to a commit SHA rather than to a branch name. Commits made here are not on any named branch and may be garbage-collected.

git checkout abc1234 causes detached HEAD state.

upstream (branch)

The remote-tracking branch that a local branch is configured to track. git pull and git push use this by default.

git branch --set-upstream-to=origin/main main

Remote

A named reference to another Git repository. The most common remote is origin.

git remote add origin git@github.com:org/project.git

origin

The conventional name for the remote you cloned from. Just a convention — the name can be anything.

git push origin main

upstream (remote)

In open-source fork workflows, the conventional name for the original repository you forked from (as opposed to origin which is your fork).

git remote add upstream https://github.com/org/project.git

Remote-tracking branch

A read-only local reference to the state of a branch on a remote. Updated by git fetch.

origin/main is a remote-tracking branch.

Tracking branch

A local branch with an upstream configured. git pull knows where to pull from without arguments.

git checkout -b main origin/main creates a tracking branch.

ORIG_HEAD

A ref created automatically before operations that change HEAD dramatically (merge, rebase, reset). Allows undo.

git reset --hard ORIG_HEAD undoes a merge.

FETCH_HEAD

Records the branch/commit fetched in the most recent git fetch. Used by git pull internally.

git fetch && git diff HEAD FETCH_HEAD

MERGE_HEAD

Points to the commit being merged during an in-progress merge.

Exists only while a merge is paused for conflict resolution.

Mainline

The primary integration branch of a project — usually main or master.

All feature branches merge back to the mainline.

History and Rewriting

Term

Definition

Example

Merge

The act of integrating changes from one branch into another. Creates a merge commit (in a no-fast-forward merge) that has two parents.

git merge feature/login on main merges the feature in.

Fast-forward merge

A merge where the target branch has not diverged — Git simply advances the branch pointer to the source commit. No merge commit is created.

git merge feature/login --ff-only

Three-way merge

The standard merge algorithm. Finds the common ancestor of both branches and compares both sides' changes relative to it. Required when both branches have new commits.

Happens automatically when both branches have diverged.

Merge commit

A commit with two parent commits, created by a non-fast-forward merge. Marks where two branches were joined.

Has a message like "Merge branch 'feature' into main"

Rebase

Moves or replays commits from one branch onto another base. Rewrites commit history — creates new commits with new SHAs.

git rebase main replays your branch on top of main.

Interactive rebase

A rebase where you can pick, squash, reword, edit, drop, or reorder commits in a text editor.

git rebase -i HEAD~5 to edit the last 5 commits.

Cherry-pick

Apply the changes from one specific commit onto the current branch, creating a new commit with the same changes but a different SHA.

git cherry-pick abc1234 applies that one commit here.

Squash

Combining multiple commits into one. Done during interactive rebase (squash or fixup commands) or via git merge --squash.

git rebase -i then mark commits with squash

Fixup

Like squash but automatically discards the fixup commit's message, keeping only the original commit's message.

Mark a commit with fixup in interactive rebase.

Amend

Modify the most recent commit — change the message, add files, or both. Creates a replacement commit (new SHA).

git commit --amend -m "Better message"

Reflog

A log of where HEAD has been. Local to your machine, not pushed. The primary recovery tool for lost commits.

git reflog shows every position HEAD has visited.

Reachable

A commit is reachable if there is a chain of parent pointers from a named ref (branch, tag, HEAD) to it.

All commits on main are reachable from the main ref.

Unreachable

A commit with no ref pointing to it (directly or through its descendants). Unreachable objects are eventually garbage-collected.

Commits dropped by git reset --hard become unreachable.

Garbage collection (GC)

Git's process of removing unreachable objects and repacking the object database for efficiency.

git gc runs manually; also runs automatically.

File States

Term

Definition

Example

Tracked

A file that Git knows about — it was previously staged and committed. Git monitors it for changes.

All files in a cloned repository are tracked.

Untracked

A file in the working tree that Git has never seen. Not staged, not committed.

A newly created file before git add.

Ignored

A file excluded from Git tracking by a .gitignore rule. Not shown in git status.

Files matching node_modules/ in .gitignore.

Modified

A tracked file whose working tree content differs from the index.

An edited source file before git add.

Staged

A file whose changes have been added to the index, ready for the next commit.

A file after git add but before git commit.

Clean

A working tree with no uncommitted changes — working tree matches HEAD.

git status shows "nothing to commit, working tree clean"

Dirty

A working tree with uncommitted changes (staged or unstaged).

After editing a file without committing.

Conflict

A file with unresolved merge conflicts, marked with <<<<<<<, =======, and >>>>>>> markers.

Appears after a failed merge or rebase.

Diff and Patch

Term

Definition

Example

Diff

A representation of the changes between two versions of a file or set of files. Shows lines added (+) and removed (-).

git diff HEAD~1..HEAD shows changes in the last commit.

Hunk

A single contiguous block of changes within a diff. A file can have multiple hunks separated by unchanged context lines.

git add -p lets you stage individual hunks.

Patch

A diff file that can be applied to recreate changes. Produced by git diff or git format-patch.

git apply fix.patch applies a patch file.

Context lines

Unchanged lines surrounding a changed hunk in a diff. Provide context for the change. Default: 3 lines.

git diff -U5 shows 5 context lines instead of 3.

Collaboration and Workflow

Term

Definition

Example

Clone

A full local copy of a remote repository, including all history, branches, and tags.

git clone git@github.com:org/project.git

Fork

A server-side copy of a repository under your own account. You have write access to your fork, not the original.

Clicking "Fork" on GitHub creates a fork.

Pull Request (PR)

A request to merge changes from one branch (or fork) into another. Provides a place for review and discussion.

Opening a PR on GitHub to merge feature/login into main.

Merge Request (MR)

GitLab's name for a pull request.

Same concept as a PR, different platform.

Code review

The process of examining proposed changes before they are merged, for quality, correctness, and knowledge sharing.

A reviewer comments on and approves a PR.

Hook

A script in .git/hooks/ that Git runs automatically at specific points (pre-commit, post-commit, pre-push, etc.).

pre-commit hook runs linting before each commit.

Bare repository

A repository with no working tree — only the .git directory contents. Used for remote servers and sharing.

git init --bare creates a bare repo.

Shallow clone

A clone with a truncated history, fetching only the last N commits. Faster for CI pipelines.

git clone --depth=1 clones only the latest commit.

Sparse checkout

A mode where only a subset of the files in a commit are written to the working tree.

git sparse-checkout set packages/ui checks out only that package.

LFS (Large File Storage)

A Git extension for storing large binary files outside the main repository. The repo stores pointers; actual files are on an LFS server.

Used for game assets, videos, large datasets.

GPG signing

Using a GPG private key to cryptographically sign commits and tags, proving authorship.

git config commit.gpgSign true

Submodule

A repository embedded within another repository at a specific commit. The parent repo stores only the submodule's URL and commit SHA.

git submodule add https://github.com/org/lib.git lib

Subtree

A strategy for including another project's history inside your repository, without submodule complexity.

git subtree add --prefix=lib https://... main --squash

Debugging

Term

Definition

Example

Blame

A Git command that shows which commit last changed each line of a file, with author and date.

git blame src/auth.ts to see who changed each line.

Bisect

A binary search tool that helps find which commit introduced a bug. You mark commits as "good" or "bad" and Git narrows it down.

git bisect start && git bisect bad && git bisect good v1.0.0

Reflog expiry

Reflog entries are not kept forever. By default, reachable entries expire after 90 days; unreachable after 30 days.

Configure with gc.reflogExpire and gc.reflogExpireUnreachable.