Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Git vocabulary: the essential terms

45 min read
Improve this page

When Git prints "HEAD detached", "hunk" or "upstream tracking", most beginners do not know exactly what it means, and guides often assume you already do. This page covers about 40 Git terms with a precise definition, the matching command and an example. Keep it as a reference: the other guides on the site link straight to the terms they use.

What you will learn

This page is organized by area:

  • Internal objects: how Git really stores your data (blob, tree, SHA, packfile)
  • Working areas: the states of your files between editing and commit
  • Pointers: HEAD, branches, refs, ORIG_HEAD
  • Index and changes: hunk, patch, stash, reflog
  • Synchronization: remote, upstream, fetch, refspec
  • History manipulation: rebase, cherry-pick, squash, reset, bisect
  • Repositories and collaboration: bare repository, orphan branch, worktree, fork, pull request
  • Advanced integration: submodule, subtree, hooks

Git internal objects

Git does not store files or diffs. It stores immutable objects in a local database (the .git/objects/ folder). Everything Git knows is one of these four object types.

Blob

A blob (Binary Large OBject) is the object that stores the raw content of a file. Not its name, not its permissions, only the bytes of the file. Two identical files in two different folders share the same blob object. This is automatic and transparent deduplication.

Terminal window
# Show the content of a blob (content of README.md at the HEAD commit)
git cat-file -p HEAD:README.md
# Show the type of a Git object
git cat-file -t abc1234
# blob

Tree

A tree is the object that represents a directory. It contains a list of entries: each entry points to a blob (file) or to another tree (subfolder), with the name and the permissions.

A commit points to a root tree, which points to all the blobs and subtrees of the project. This tree structure is what makes up the full "snapshot" of the project at a given moment.

Terminal window
# Show the content of the root tree of the latest commit
git cat-file -p HEAD^{tree}
# 100644 blob a8f1b3... README.md
# 100644 blob 9c2d4a... package.json
# 040000 tree 3f2c1e... src

Commit

A commit object is the snapshot of your project at a precise moment. It contains: a reference to the root tree, one or more references to its parent commits, and the metadata (author, date, message). Its SHA is not written in it: Git computes it from the content of the object.

A commit does not store a diff: it points to the complete tree. This lets Git rebuild the full state of the project at any moment without replaying all the diffs from the beginning.

Terminal window
# Show the internal content of a commit
git cat-file -p HEAD
# tree 3f2c1e8a04b6...
# parent abc12345def6...
# author Jean Dupont <jean@example.com> 1711234567 +0100
# committer Jean Dupont <jean@example.com> 1711234567 +0100
#
# Ajout de la page d'accueil

Tag

A tag (label) marks a specific commit, usually a published version. There are two types:

TypeCommandSeparate objectRecommended for
Lightweightgit tag v1.0NoQuick local marking
Annotatedgit tag -a v1.0 -m "Version 1.0"Yes (with its own SHA)Official releases

Annotated tags are recommended for releases: they have their own SHA and contain a message, a creation date and an author of their own. They can be GPG-signed (-s) and they show up in git describe.

Terminal window
# Create an annotated tag
git tag -a v2.1.0 -m "Release 2.1.0 : support multi-tenant"
# List tags
git tag -l "v2.*"
# Show the details of an annotated tag
git show v2.1.0

SHA and hash

The SHA is the unique identifier of each Git object. It is a hash computed from the complete content of the object. By default, Git uses SHA-1 and the identifier is 40 hexadecimal characters long. A repository created with git init --object-format=sha256 uses SHA-256, with 64-character identifiers. In both cases, the smallest change (one byte) gives a completely different SHA.

Terminal window
# Full SHA of the current commit (40 characters in SHA-1)
git rev-parse HEAD
# e4a1c0f3d8b2a7f19c05d3e6b4a8f2c0e1d5b9a3
# Abbreviated SHA (7 characters, enough in practice)
git rev-parse --short HEAD
# e4a1c0f

You do not need all the characters. Git accepts any unambiguous prefix; 7 or 8 characters are usually enough. If two objects share the same prefix, Git asks you to make it longer.

The SHA plays two roles: it identifies the object and it lets you check its integrity. If an object is corrupted or altered during a transfer, its recomputed SHA no longer matches, and Git detects the error.

Packfile

A packfile is an optimized storage format that groups several Git objects into a single compressed file. Git first stores each object separately in .git/objects/, then periodically groups them into a packfile to save disk space.

Terminal window
# Trigger the creation of a packfile manually
git gc
# List the packfiles
ls -lh .git/objects/pack/
# total 48M
# -rw-r--r-- 1 bob bob 48M Mar 28 10:42 pack-abc123.pack
# -rw-r--r-- 1 bob bob 512K Mar 28 10:42 pack-abc123.idx

Packfiles use delta compression internally: instead of storing every version of a file in full, Git can store some objects as "base object + delta of changes". This is an implementation detail that is transparent to the user.

Delta

A delta is the representation of a Git object as the difference from another, base object, used inside packfiles to save space.


Working areas

Git manages your files through three distinct areas. Understanding these areas is the key to demystifying almost every Git command.

Working directory

The working directory is the folder of your project as you see it and edit it in your editor or terminal. This is where your real files live. Git watches for differences between the working directory and its index (staging area).

File stateMeaning
UntrackedGit does not know this file yet
ModifiedChanged since the last commit, not staged
StagedAdded to the staging area, ready for the commit
CommittedRecorded in the repository
Terminal window
# Show the state of your working directory
git status
# Short version
git status -s
# M fichier.js ← left column = staged, right column = not staged
# M autre.js
# ?? nouveau.js ← untracked

Staging area

The staging area (also called the index) is the intermediate area between the working directory and the repository. It holds the exact state of what your next commit will be. git add moves files or parts of files into it; git commit turns its content into a permanent commit.

Working directory →(git add)→ Staging area →(git commit)→ Repository

Why this intermediate step? It lets you commit only part of your changes, even only part of a file with git add -p. If you changed 10 files, you can create two clean commits by staging 5 files at a time.

Terminal window
# Show what is in the staging area (difference with the last commit)
git diff --staged
# Remove a file from the staging area (without touching the working dir)
git restore --staged fichier.js
# Show the index in detail
git ls-files --stage

Repository

The repository is the Git database that stores the whole history of your project. It lives in the .git/ folder at the root of your project. It contains all the objects (blobs, trees, commits, tags), all the branches, all the tags and the local configuration.

Terminal window
# The .git folder contains the whole database
ls .git/
# COMMIT_EDITMSG HEAD config hooks/ index objects/ refs/
# Show the size of the repository
du -sh .git/

Pointers and references

HEAD is the pointer that tells you where you are in Git. In most cases, HEAD points to the active branch (for example main), which itself points to the latest commit of that branch. When you commit, HEAD (and therefore the branch) moves forward automatically.

HEAD → main → commit e4a1c0f → commit parent → ...
refs/heads/main
# Show what HEAD points to
cat .git/HEAD
# Show the SHA of the commit HEAD points to
git rev-parse HEAD
# Use in commands
git show HEAD # latest commit
git show HEAD~1 # one commit before
git show HEAD~2 # two commits before
git diff HEAD~1 HEAD # difference between the last two commits

Detached HEAD

The "detached HEAD" state means HEAD points directly to a commit, not to a branch. Normally, HEAD points to a branch that points to a commit. In detached HEAD, HEAD jumps over the branch and points directly to a SHA.

Normal : HEAD → main → e4a1c0f
Detached : HEAD → e4a1c0f (no branch in between)

When it happens: git checkout <sha>, git checkout <tag>, while git rebase is running.

The risk: any commit created in detached HEAD belongs to no branch. If you move elsewhere without creating a branch, those commits become orphaned and will be deleted by git gc after 30 days.

Terminal window
# Git warns you
git checkout abc1234
# HEAD is now at abc1234 Mon commit
# You are in 'detached HEAD' state.
# Solution: create a branch to save the work
git switch -c branche-de-sauvegarde

→ Dedicated guide: Detached HEAD: navigating without a branch (in French)

Ref

A ref (reference) is any symbolic name that points to a Git object, usually a commit. Branches, tags, HEAD and the special references are all refs. Git stores them in .git/refs/ as text files.

Ref typeExamplesLocation in .git/
Local branchmain, feature/loginrefs/heads/
Remote branchorigin/mainrefs/remotes/
Tagv1.0, v2.0-rc1refs/tags/
HEADCurrent positionHEAD
SpecialORIG_HEAD, MERGE_HEADroot of .git/
Terminal window
# Show all the refs of the repository
git show-ref
# Resolve the SHA of a ref
git rev-parse refs/heads/main

ORIG_HEAD, MERGE_HEAD, FETCH_HEAD

Git creates temporary references to save important states. MERGE_HEAD disappears at the end of the merge; ORIG_HEAD and FETCH_HEAD stay until the next operation that rewrites them.

ORIG_HEAD: Git saves the old HEAD here before any risky operation (merge, rebase, reset). This lets you go back to the previous state with a single command.

Terminal window
# Before: git rebase main (which went wrong)
git reset --hard ORIG_HEAD # back to the previous state

MERGE_HEAD: present during a merge with conflicts. Git stores there the SHA of the branch being merged. It disappears after git commit or git merge --abort.

FETCH_HEAD: contains the SHA of the remote branch fetched by the last git fetch. git pull uses FETCH_HEAD to know what to merge after the fetch.

Terminal window
# Show the content after a fetch
cat .git/FETCH_HEAD
# abc1234 branch 'main' of https://github.com/user/projet.git

Index and changes

Hunk

A hunk is a contiguous block of changed lines in a diff. A modified file can contain several hunks, separated by unchanged lines. Git uses this splitting so you can stage or skip changes block by block, not file by file.

@@ -15,4 +15,6 @@ def calculate():
result = 0
- for i in range(10):
+ for i in range(100):
+ if i % 2 == 0:
+ continue
result += i
return result

The header @@ -15,4 +15,6 @@ reads: "in the original, this block starts at line 15 and spans 4 lines; in the new version, it starts at line 15 and spans 6 lines". Count: 4 lines before (result = 0, for, result += i, return), 6 after (the 2 extra lines that were added).

When you run git add -p, Git shows you the hunks one by one and asks, for each one: stage it (y), skip it (n), split it into smaller ones (s) or edit it manually (e).

Terminal window
# Stage hunk by hunk
git add -p
# Main prompt options
# y = yes (stage this hunk)
# n = no (skip this hunk)
# s = split (split into smaller hunks)
# e = edit (manually edit the lines to stage)
# q = quit

→ Dedicated guide: Interactive staging (in French)

Patch

A patch is a text file that contains one or more hunks, with the metadata needed to apply them to other code. It is the traditional exchange format in open source workflows (the Linux kernel in particular).

Terminal window
# Create a patch file for the last commit
git format-patch HEAD~1
# 0001-Mon-commit.patch
# Apply a patch
git apply 0001-Mon-commit.patch
# Apply a patch with the commit metadata (author, date)
git am 0001-Mon-commit.patch

Stash

The stash is a temporary stack where Git saves your uncommitted changes. git stash records the state of the working directory and the staging area, then puts everything back in the state of the last commit. git stash pop reapplies the saved changes.

Modified working directory
↓ git stash
Clean working directory + stash holds your changes
↓ git stash pop
Modified working directory (restored)
Terminal window
# Set your changes aside
git stash
# Show the list of stashes (LIFO stack)
git stash list
# stash@{0}: WIP on main: e4a1c0f Ajout login
# stash@{1}: WIP on feature: abc1234 En cours
# Restore the latest stash
git stash pop
# Name a stash (easier to read)
git stash push -m "feature login - formulaire incomplet"
# Also stash untracked files
git stash -u
# Restore a specific stash without deleting it
git stash apply stash@{1}

→ Dedicated guide: Git stash and git clean (in French)

Reflog

The reflog (reference log) is the journal of all the movements of HEAD and of the branches in your local repository. Each time HEAD changes (commit, checkout, merge, rebase, reset), Git records an entry in the reflog. It is kept 90 days by default, and only 30 days for an entry that has become unreachable from the references (gc.reflogExpireUnreachable).

It is your safety net. A commit "lost" after a reset --hard? A commit created in detached HEAD and abandoned? Everything is in the reflog as long as the delay has not expired.

Terminal window
# Show the reflog of HEAD
git reflog
# e4a1c0f HEAD@{0}: commit: Ajout de la page d'accueil
# 3f2c1b0 HEAD@{1}: checkout: moving from feature to main
# abc1234 HEAD@{2}: reset: moving to HEAD~1
# def5678 HEAD@{3}: commit: Feature login
# Recover the "lost" commit: the one from before the reset (def5678)
git switch -c branche-rescue def5678

→ Dedicated guide: Recovering lost data (in French)


Remote synchronization

Remote

A remote is a Git repository hosted elsewhere, on GitHub, GitLab, an internal server, or even another folder on your machine. In your local repository, a remote is a named reference to the URL of that remote repository. You can have several in the same project.

Terminal window
# Show the configured remotes
git remote -v
# origin https://github.com/user/projet.git (fetch)
# origin https://github.com/user/projet.git (push)
# Add a remote
git remote add backup https://gitlab.com/user/projet.git
# Rename a remote
git remote rename origin ancien-origin
# Remove a remote
git remote remove backup

Origin

Origin is the conventional name of the main remote, typically the repository you cloned from. This name is not mandatory: it is a convention followed by Git and all the tools. git clone creates it automatically. You can rename it or use another one.

Terminal window
# Origin is created automatically by git clone
git clone https://github.com/user/projet.git
cd projet
git remote -v
# origin https://github.com/user/projet.git (fetch)
# origin https://github.com/user/projet.git (push)

Upstream

The term "upstream" has two meanings depending on the context:

1. The remote branch tracked by a local branch. When you run git push -u origin main, you configure origin/main as the upstream of your local main. After that you can use git push and git pull without arguments.

Terminal window
# Configure the upstream of a branch
git push -u origin feature/login
# Show the configured upstream of each local branch
git branch -vv
# * main e4a1c0f [origin/main] Mon commit
# feature abc1234 [origin/feature: ahead 2] Ma feature
# "ahead 2" = 2 local commits not pushed yet
# "behind 3" = 3 remote commits not fetched yet

2. The original repository in a fork workflow. If you fork a project on GitHub, the original repository is conventionally called "upstream" and your fork is called "origin".

Terminal window
# Classic fork configuration
git remote add upstream https://github.com/projet-original/projet.git
git remote add origin https://github.com/votre-fork/projet.git
# Fetch the updates of the original
git fetch upstream
git merge upstream/main

Tracking branch

A tracking branch is a local branch configured to follow a remote branch. It automatically knows where git push must send and where git pull must fetch from.

Terminal window
# Create a local branch that tracks a remote branch
git switch --track origin/feature-xyz
# Branch 'feature-xyz' set up to track remote branch 'feature-xyz' from 'origin'.
# Show all the branches and their tracking
git branch -vv

Fetch

git fetch downloads the new data from the remote without changing your working directory or your local branches. It updates the remote references (origin/main, etc.) but does not touch your local main. git pull is essentially git fetch + git merge.

Before fetch: origin/main out of sync with the server
↓ git fetch
After fetch : origin/main = current state of the server
local main = unchanged (you decide when to merge)
Terminal window
# Download without merging
git fetch origin
# See what changed upstream before deciding
git log HEAD..origin/main --oneline
# Then merge manually
git merge origin/main
# (or: git pull = fetch + merge in one command)

Refspec

A refspec is the syntax that defines which references to transfer between the local repository and the remote. Format: [+]<src>:<dst>. It appears in the .git/config configuration and in the git fetch and git push commands.

Terminal window
# Standard refspec created by git clone (in .git/config)
# fetch = +refs/heads/*:refs/remotes/origin/*
# Means: fetch all the branches of the remote (refs/heads/*)
# and store them locally under refs/remotes/origin/*
# Push a local branch to a different name on the remote
git push origin feature:feature-v2
# Delete a remote branch (empty source)
git push origin :ancienne-branche
# equivalent:
git push origin --delete ancienne-branche

Manipulating history

Fast-forward

A fast-forward is a type of merge where Git simply moves the branch pointer forward without creating a merge commit. It is only possible when the branch to integrate is directly ahead of the target branch, with no divergence: in other words, all the commits of the target are already ancestors of the source branch.

Before fast-forward:
A ──► B ──► C ──► D
▲ ▲
main feature
git merge feature (from main)
After fast-forward:
A ──► B ──► C ──► D
▲
main, feature
(main just "moved forward" to D, without a merge commit)
Terminal window
# Merge as a fast-forward (default behavior when possible)
git merge feature
# Force a merge commit even if fast-forward is possible
git merge --no-ff feature
# Refuse if fast-forward is not possible
git merge --ff-only feature

→ Dedicated guide: Merge and conflicts (in French)

Rebase

git rebase replays your commits on a new base. Instead of creating a merge commit, it moves your commits (by recreating them with new SHAs) as if they had been created after the commits of the target branch.

Before rebase:
main ──► A ──► B ──► C
feature ──► A ──► D ──► E
git rebase main (from feature)
After rebase:
main ──► A ──► B ──► C
feature ──────────────────► D' ──► E'
(D' and E' are new versions of D and E, with new SHAs)
Terminal window
# Rebase the current branch onto main
git rebase main
# Interactive rebase: reorder, squash, edit commits
git rebase -i HEAD~5
# Cancel a rebase in progress
git rebase --abort
# Continue after resolving a conflict
git rebase --continue

→ Dedicated guide: Rebase fundamentals (in French)

Cherry-pick

git cherry-pick copies a specific commit and applies it to the current branch. It recreates the commit with a new SHA (since the context is different). Useful for backports (porting a fix to a maintenance branch) or targeted hotfixes.

main ──► A ──► B ──► C ──► D
feature ──► A ──► X ──► Y
git cherry-pick D (from feature)
feature ──► A ──► X ──► Y ──► D'
(D' is a copy of D with a new SHA)
Terminal window
# Apply a specific commit to the current branch
git cherry-pick abc1234
# Apply a range of commits
git cherry-pick abc1234..def5678
# Cherry-pick without creating a commit (resolve manually)
git cherry-pick --no-commit abc1234

→ Dedicated guide: Cherry-pick (in French)

Squash

Squashing commits means combining them into a single commit. It is an operation of git rebase -i: you select several commits and merge them into one commit with a combined or new message. Useful for cleaning up a series of "WIP" commits before merging.

Before squash:
A ──► B ──► C ──► D (B, C, D are "WIP: in progress")
git rebase -i HEAD~3 (with squash on C and D)
After squash:
A ──► E (E is a clean commit that combines B+C+D)
Terminal window
# Open the editor for the last 3 commits
git rebase -i HEAD~3
# In the editor, change "pick" to "squash" or "s"
# pick abc1234 Feature principale
# squash def5678 WIP: ajout test
# squash ghi9012 WIP: fix lint

→ Dedicated guide: Rewriting history (in French)

Revert

git revert undoes a commit by creating a new commit that applies the inverse of the changes. Unlike reset, it does not modify the existing history, it adds an undo commit to it. It is the safe way to undo on a shared branch.

Terminal window
# Undo the last commit (creates a new undo commit)
git revert HEAD
# Undo a specific commit in the history
git revert abc1234
# Prepare the revert without creating the commit right away
git revert --no-commit abc1234
git revert --no-commit def5678
git commit -m "Annulation des features X et Y"

Reset

git reset moves the current branch (and therefore HEAD) to an earlier commit. It has three modes that differ by their impact on the staging area and the working directory:

ModeCommandStaging areaWorking directory
Softgit reset --soft HEAD~1PreservedPreserved
Mixed (default)git reset HEAD~1EmptiedPreserved
Hardgit reset --hard HEAD~1EmptiedReset
Terminal window
# Undo the last commit, keeping the changes in the staging area
git reset --soft HEAD~1
# Undo the last commit, putting the changes back in the working directory
git reset HEAD~1
# Undo and DISCARD all changes (irreversible without the reflog)
git reset --hard HEAD~1

→ Dedicated guide: Reset demystified (in French)

Bisect

git bisect finds the commit that introduced a bug using binary search. You give it a "good" commit (before the bug) and a "bad" commit (with the bug). Git picks the middle commit, you test it, mark it good or bad, and so on. For n commits, it takes about log2(n) steps to isolate the faulty commit.

Commits: A B C D E F G H I J K L
A is good, L is bad.
Bisect tests F (middle) → "good"
Bisect tests I → "bad"
Bisect tests G → "bad"
Result: F is good and G is bad, so G is the first bad commit.
Terminal window
# Start a bisect session
git bisect start
# Mark the current commit as bad
git bisect bad
# Mark an old, known commit as good
git bisect good v2.0
# For each commit proposed by Git: test and answer
git bisect good # or
git bisect bad
# Finish and go back to the normal branch
git bisect reset
# Automate with a test script (0 = good, non-0 = bad)
git bisect run npm test

→ Dedicated guide: Debugging with bisect and blame (in French)


Repositories and collaboration

Bare repository

A bare repository is a Git repository without a working directory. It only contains what is in the .git/ folder of a normal repository. This is the type of repository used on Git servers (GitHub, GitLab, your internal server): it receives pushes and serves clones, but nobody works directly in it.

Terminal window
# Create a bare repository (to serve as a remote)
git init --bare mon-projet.git
# Clone while keeping the bare format
git clone --bare https://github.com/user/projet.git

→ Dedicated guide: Hosting your own Git server (in French)

Orphan branch

An orphan branch is a branch with no common history with the rest of the repository. Its first commit has no parent. Useful for creating a gh-pages branch (documentation) or a docs branch entirely independent of the source code.

Terminal window
# Create an orphan branch (without history)
git switch --orphan gh-pages
# The branch is empty and has no parent
git status
# On branch gh-pages
#
# No commits yet

Worktree

git worktree lets you have several working directories attached to the same repository at the same time. You can work on two different branches in two separate folders, without stash and without an extra clone.

Terminal window
# Create a second working directory on the "hotfix" branch
git worktree add ../projet-hotfix hotfix/urgent
# Show all the active worktrees
git worktree list
# /home/bob/projet e4a1c0f [main]
# /home/bob/projet-hotfix abc1234 [hotfix/urgent]
# Remove a worktree
git worktree remove ../projet-hotfix

The guide Git worktree: several branches at the same time (in French) covers the creation step by step, what worktrees really share and the pitfalls to know about (dependencies, untracked files, shared hooks).

Fork

A fork is a copy of a repository on a platform (GitHub, GitLab). Unlike a local clone, a fork is an independent remote repository under your account. It is used in the open source contribution workflow: you fork, work on your fork, then propose your changes through a pull request to the original repository.

Terminal window
# After forking on GitHub, clone your fork
git clone https://github.com/VOTRE-COMPTE/projet.git
cd projet
# Add the original repository as "upstream"
git remote add upstream https://github.com/ORIGINAL/projet.git
# Fetch the updates of the original
git fetch upstream
git merge upstream/main

Pull Request and Merge Request

A Pull Request (PR on GitHub) or Merge Request (MR on GitLab) is a formal request to merge one branch into another, with a code review interface, comments, CI/CD pipelines and a validation before the merge. It is not a feature of Git itself, it is a layer added by the hosting platforms.

PlatformTermAcronym
GitHubPull RequestPR
GitLabMerge RequestMR
BitbucketPull RequestPR
Azure DevOpsPull RequestPR

→ Dedicated guide: Pull requests and code review (in French)


Advanced integration

Submodule

A submodule is a Git repository nested inside another Git repository. The parent repository stores a pointer to a precise SHA of the sub-repository (not its content). Useful for referencing an external library while pinning a precise version.

Terminal window
# Add a submodule
git submodule add https://github.com/lib/librairie.git libs/librairie
# Clone a repository with its submodules
git clone --recurse-submodules https://github.com/user/projet.git
# Update all the submodules to their latest version
git submodule update --remote

→ Dedicated guide: Git submodules (in French)

Subtree

git subtree integrates the content of an external repository directly into a subfolder of your repository. Unlike submodules, the files are copied and become part of your repository's history. Simpler day to day, because contributors do not need any special command to clone.

Terminal window
# Add a sub-project as a subtree
git subtree add --prefix=libs/ma-lib \
https://github.com/lib/ma-lib.git main --squash
# Update the subtree
git subtree pull --prefix=libs/ma-lib \
https://github.com/lib/ma-lib.git main --squash

→ Dedicated guide: Git subtree (in French)

Hooks

Git hooks are scripts run automatically on specific Git events, before a commit, after a push, before a merge, and so on. They are stored in .git/hooks/ and are local (not versioned by default).

HookTriggerCommon use cases
pre-commitBefore each commitLint, formatting, quick tests
commit-msgMessage validationConventional Commits format
pre-pushBefore each pushIntegration tests
post-mergeAfter a successful mergeDependency update
prepare-commit-msgWhen the commit editor opensPre-fill the message
# Create a pre-commit hook (example: run eslint)
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/sh
npm run lint
exit $?
EOF
chmod +x .git/hooks/pre-commit

Key takeaways

TermOne-sentence definition
BlobRaw content of a file in the Git database
TreeDirectory in the Git database
SHA / hashUnique identifier of each object (40 characters in SHA-1, 64 in SHA-256)
PackfileOptimized, compressed storage format for Git objects
Working directoryYour files as you see and edit them
Staging area / IndexIntermediate area between editing and commit
RepositoryThe Git database (the .git/ folder)
HEADPointer to your current position in the history
Detached HEADHEAD points to a commit, not to a branch
RefAny symbolic name pointing to a Git object
ORIG_HEADAutomatic backup of HEAD before a risky operation
HunkContiguous block of changed lines in a diff
StashTemporary stack of uncommitted changes
ReflogLocal journal of all HEAD movements (90 days, 30 if the entry has become unreachable)
RemoteNamed reference to a remote Git repository
OriginConventional name of the main remote
UpstreamTracked remote branch / original repository of a fork
FetchDownload remote data without merging
Refspecsrc:dst syntax for reference transfers
Fast-forwardMerge without a merge commit (simple pointer move)
RebaseReplay commits on a new base
Cherry-pickCopy a specific commit onto the current branch
SquashCombine several commits into one
RevertUndo a commit by creating an undo commit
ResetMove the current branch (and HEAD) to an earlier commit
BisectBinary search for the faulty commit
Bare repositoryRepository without a working directory (used on servers)
ForkCopy of a repository on a platform (GitHub, GitLab)
Pull Request / MRFormal merge request with code review
SubmoduleGit repository nested inside another one
HooksScripts run automatically on Git events

Knowledge check

Check that you have the essentials of this guide. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

10 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer