Git Glossary
This glossary explains common Git terms and gives short command examples for quick reference.
Core Concepts
Repository
A repository is a project directory tracked by Git. It contains your working files and the complete version history stored in the .git directory.
Commit
A commit is a saved snapshot of staged changes. Each commit has a unique hash, an author, a timestamp, and a message.
Branch
A branch is a movable pointer to a commit. Branches let you work on features, fixes, or experiments without changing the main line of development.
HEAD
HEAD points to the commit currently checked out in your working tree. In normal work it points to the latest commit of the current branch.
Working Tree
The working tree is the set of files you can edit directly. It may contain tracked, modified, staged, and untracked files.
Staging Area
The staging area, also called the index, holds changes that will be included in the next commit.
Daily Workflow
Add
git add moves changes from the working tree into the staging area.
Status
git status shows the current branch, staged changes, unstaged changes, and untracked files.
Diff
git diff shows changes between the working tree, the staging area, commits, or branches.
Log
git log displays commit history.
Branching And Merging
Checkout
git checkout can switch branches or restore files. In newer Git versions, prefer git switch for branches and git restore for files.
Switch
git switch changes the current branch.
Merge
git merge integrates changes from another branch into the current branch.
Fast-Forward Merge
A fast-forward merge happens when the target branch has no new commits of its own, so Git can simply move the branch pointer forward.
Three-Way Merge
A three-way merge uses two branch tips and their common ancestor to combine changes. It creates a merge commit when a fast-forward is not possible.
Merge Conflict
A merge conflict happens when Git cannot automatically combine changes. You must edit the conflicted files, stage them, and complete the merge.
Rebase
git rebase reapplies commits on top of another base commit. It is often used to keep feature branches up to date with main.
Cherry-Pick
git cherry-pick applies one specific commit to the current branch.
Remote Collaboration
Remote
A remote is a named reference to another repository, usually hosted on a service such as GitHub or GitLab.
Origin
origin is the default name Git gives to the remote repository you cloned from.
Upstream
An upstream branch is the remote branch tracked by a local branch. It lets Git know where to pull from and push to by default.
Fetch
git fetch downloads remote commits and branch references without merging them into your current branch.
Pull
git pull fetches remote changes and then integrates them into the current branch.
Push
git push uploads local commits to a remote repository.
Pull Request
A pull request is a review workflow used by hosting platforms. It proposes merging changes from one branch into another.
Fork
A fork is a personal copy of a repository on a hosting platform. It is commonly used for open-source contributions.
Undo And Recovery
Restore
git restore discards or unstages changes.
Reset
git reset moves the current branch pointer. Depending on the mode, it can also update the staging area and working tree.
Revert
git revert creates a new commit that undoes an earlier commit without rewriting history.
Stash
git stash temporarily saves uncommitted changes so you can switch context.
Reflog
git reflog records recent movements of HEAD and branch references. It is useful for recovering commits after an accidental reset or rebase.
Tags And Metadata
Tag
A tag is a fixed reference to a commit, often used for releases.
Annotated Tag
An annotated tag stores extra metadata, including tagger, date, and message. It is recommended for release tags.
Lightweight Tag
A lightweight tag is a simple name pointing to a commit, without extra metadata.
SHA
Git uses SHA hashes to identify objects such as commits, trees, and blobs.
Blob
A blob is the Git object type used to store file contents.
Tree
A tree is the Git object type used to store directory structure.
Project Hygiene
Gitignore
.gitignore lists files and directories Git should ignore.
Hook
A hook is a script Git runs automatically during certain events, such as before a commit or before a push.
Common hooks include:
pre-commitcommit-msgpre-push
Submodule
A submodule lets one Git repository include another repository at a specific commit.
Worktree
A worktree lets you check out multiple branches of the same repository into separate directories.