Understanding HEAD and Detached HEAD State
Understanding Git’s HEAD reference system is fundamental to mastering version control workflows. This concept often confuses developers transitioning from other systems, yet it represents one of Git’s most elegant architectural decisions. This guide provides a comprehensive exploration of HEAD’s behavior, with particular emphasis on the detached HEAD state—a powerful but frequently misunderstood feature.
HEAD: Git’s Position Tracking Mechanism
HEAD represents your current position within the repository’s commit graph. Every Git operation that reads or modifies the working tree references HEAD to determine the baseline state. Understanding HEAD’s behavior is essential for effective repository navigation and manipulation.
The Reference Chain: How HEAD Works
In standard workflows, HEAD functions as a symbolic reference—a pointer that references a branch, which in turn points to a specific commit:
HEAD → refs/heads/main → commit abc1234This indirection mechanism provides critical functionality. When you create new commits, Git updates the branch reference to point to the new commit, and HEAD automatically tracks this movement through its symbolic link to the branch.
Inspecting HEAD’s Current State:
# Display HEAD's symbolic reference
cat .git/HEAD
# Output: ref: refs/heads/main
# Resolve HEAD to its commit SHA
git rev-parse HEAD
# Output: abc1234def5678...
# View detailed HEAD information
git log -1 HEADTechnical Implementation: Git stores HEAD as a file in .git/HEAD. When
HEAD points to a branch, this file contains a text reference to that branch.
When detached, it contains a raw commit SHA.
Detached HEAD State: Architecture and Behavior
Detached HEAD occurs when HEAD points directly to a commit SHA rather than to a branch reference. This state modification changes Git’s operational semantics in important ways.
Structural Comparison
Normal Branch-Attached State:
HEAD → refs/heads/main → commit C
↓
A ← B ← CIn this configuration, commits created will advance the main branch reference.
Detached HEAD State:
HEAD → commit B
↓
A ← B ← C ← mainIn this configuration, HEAD references commit B directly. New commits will extend the history from B, but no branch reference will track them automatically.
Operational Triggers: When Detached HEAD Occurs
Git transitions to detached HEAD state in specific, well-defined scenarios. Understanding these triggers helps developers recognize when they’re entering this state and why Git has chosen this behavior.
Explicit Commit Checkout
Direct commit checkout represents the most common detached HEAD trigger:
# Checkout specific commit by SHA
git checkout abc1234
# Checkout tagged release
git checkout v2.0.0
# Relative reference navigation
git checkout HEAD~3
git checkout HEAD^^^Architectural Rationale: Git enters detached HEAD because these operations target specific historical states rather than evolving branch tips. This prevents accidental modification of branch references when examining historical snapshots.
Warning Message: Git provides clear notification when entering detached HEAD:
Note: switching to 'abc1234'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.Binary Search Operations (git bisect)
The bisect command employs detached HEAD systematically during its binary search algorithm:
git bisect start
git bisect bad # Current commit exhibits bug
git bisect good v1.0.0 # v1.0.0 was functional
# Git checks out commits in detached HEAD state for testingImplementation Detail: Bisect must navigate arbitrary commits between good and bad states. Detached HEAD prevents bisect from inadvertently modifying branch references during its automated traversal.
Workflow Integration: Each bisect step checks out a commit in detached HEAD,
allowing you to test without affecting repository structure. Once bisect
identifies the problematic commit, git bisect reset returns HEAD to its
original branch-attached state.
Worktree Isolated Environments
Worktrees frequently utilize detached HEAD for examining specific repository states:
# Create worktree at specific commit
git worktree add --detach ../inspection abc1234
# Worktree at tagged release
git worktree add ../release-validation v2.0.0Design Pattern: When worktrees are created for read-only inspection or testing of historical states, detached HEAD prevents unintended branch reference updates in isolated working directories.
Interactive Rebase Internal State
During interactive rebase operations, Git temporarily enters detached HEAD:
git rebase -i HEAD~5
# Git detaches HEAD during commit replay
# Automatically reattaches upon successful completionTransient Behavior: This detachment is internal to rebase’s implementation. The rebase process detaches HEAD, replays commits, then reattaches to the target branch. Users typically don’t interact with this intermediate state.
Submodule Operational Model
Submodules employ detached HEAD as their default operational mode:
git submodule update
# Submodules check out specific commit SHAs (detached HEAD)Architectural Decision: Submodules track specific commit hashes to ensure reproducible builds across different repository checkouts. Detached HEAD enforces this immutability—submodules remain at fixed commits until explicitly updated.
Best Practice: When developing within a submodule, explicitly create a branch:
cd path/to/submodule
git checkout -b feature-branch
# Now on branch, commits will be trackedOperational Semantics: Working in Detached HEAD
Detached HEAD modifies Git’s behavior in subtle but important ways. Understanding these modifications enables effective use of this state for legitimate workflows.
Read-Only Operations (Always Safe)
Standard inspection operations function identically in detached HEAD:
# File examination
cat src/authentication.py
git show HEAD:src/authentication.py
# History inspection
git log
git log --graph --oneline
git diff main
# Repository state queries
git status
git branch -vvPerformance Characteristic: Read operations incur no additional overhead in detached HEAD. The state affects only write operations (commits).
Creating Commits in Detached HEAD
Git permits commit creation in detached HEAD, but these commits lack branch references:
# Modify files
vim src/feature.py
git add src/feature.py
# Commit normally
git commit -m "Experimental implementation approach"
# Additional commits build upon previous
vim src/feature.py
git commit -am "Refine experimental approach"Critical Understanding: These commits exist in Git’s object database and possess valid parent relationships. However, without a branch reference pointing to them, they’re susceptible to garbage collection once unreachable from reflog.
Visualization:
git log --oneline --graph
# * def5678 (HEAD) Refine experimental approach
# * abc1234 Experimental implementation approach
# * xyz9012 Original commit where HEAD was detachedThe commits form a valid chain, but (HEAD) indicates no branch reference
tracks them.
Recovery and Transition Strategies
Detached HEAD state offers multiple exit strategies depending on whether you wish to preserve or discard work performed while detached.
Scenario 1: Discard Detached Work
If your detached HEAD exploration requires no preservation:
# Return to branch
git switch main
# Alternative
git checkout mainEffect: Commits created in detached state become unreferenced. Git’s reflog retains access for 30-90 days (configurable), after which garbage collection removes them.
Use Case: You tested an approach, determined it doesn’t work, and want to abandon it cleanly.
Scenario 2: Preserve Work via Branch Creation
When detached HEAD commits merit preservation:
Immediate Branch Creation (while still detached):
# Create branch at current HEAD position
git switch -c experimental-architecture
# Verify branch creation
git branch
# * experimental-architecture
# main
git log --oneline
# Shows your detached commits now on new branchDeferred Branch Creation (after returning to main):
# You've already returned to main
git switch main
# Locate detached commits via reflog
git reflog
# Output:
# abc1234 HEAD@{0}: checkout: moving from def5678 to main
# def5678 HEAD@{1}: commit: Experimental commit
# ghi9012 HEAD@{2}: commit: Initial experiment
# jkl3456 HEAD@{3}: checkout: moving from main to jkl3456
# Create branch pointing to detached work
git branch recovered-experiment def5678
# Verify recovery
git log recovered-experiment --onelineTechnical Note: Reflog maintains HEAD position history for approximately 90
days by default (configured via gc.reflogExpire).
Scenario 3: Selective Commit Recovery
If only specific detached commits are valuable:
# Return to main
git switch main
# Identify valuable commits
git reflog
# def5678 HEAD@{1}: commit: Valuable feature addition
# ghi9012 HEAD@{2}: commit: Experimental approach (discard)
# jkl3456 HEAD@{3}: commit: Another valuable change
# Cherry-pick specific commits
git cherry-pick def5678
git cherry-pick jkl3456
# Experimental commit (ghi9012) remains unreferenced and will be garbage collectedStrategic Application: This approach extracts valuable work while leaving failed experiments to garbage collection.
Practical Application Patterns
Detached HEAD serves legitimate, production-ready workflows when applied appropriately.
Pattern 1: Historical Bug Investigation
Scenario: A bug report references specific release versions. You need to reproduce behavior without contaminating development branches.
Implementation:
# Checkout production release
git checkout v2.1.0
# Reproduce reported issue
npm install
npm test
node scripts/reproduce-issue.js
# Compare with subsequent release
git checkout v2.2.0
npm install
npm test
# Return to development
git switch developBenefit: Detached HEAD ensures investigation occurs at exact historical states. No risk of accidentally committing to release tags or production branches.
Pattern 2: Experimental Prototyping
Scenario: Evaluating radical architectural changes without committing to branch strategy or long-term maintenance.
Implementation:
# Start from stable baseline
git checkout stable-baseline
# Enter detached HEAD
# Implement experimental architecture
vim src/new-architecture.py
git commit -am "Experimental: microservices architecture"
vim src/new-architecture.py
git commit -am "Experimental: message queue integration"
# Test experimental approach
npm test
npm run integration-tests
# Decision point:
# Success → preserve: git switch -c microservices-experiment
# Failure → abandon: git switch mainWorkflow Advantage: Low-friction experimentation. If the approach proves unviable, simply switch away—no branch cleanup, no merge conflicts, no commit history pollution.
Pattern 3: Release Verification and Artifact Generation
Scenario: QA testing or CI/CD systems require exact reproducibility at specific commit hashes.
Implementation:
# CI/CD script checks out exact commit
git checkout $COMMIT_SHA
# Now in detached HEAD at specific commit
# Build from immutable state
npm ci # Clean install from package-lock.json
npm run build
npm test
# Generate artifacts
tar -czf release-$COMMIT_SHA.tar.gz dist/
# Deploy artifacts
./deploy.sh dist/Architectural Rationale: Commit SHAs are immutable; branch names move. Detached HEAD enforces build reproducibility by preventing accidental inclusion of commits beyond the specified SHA.
Pattern 4: Comparative Performance Analysis
Scenario: Investigating performance regression requires testing multiple historical commits.
Implementation:
# Create isolated testing worktree
git worktree add --detach ../performance-testing
cd ../performance-testing
# Test commit before performance degradation
git checkout abc1234
npm install
npm run benchmark > results-abc1234.txt
# Test commit after reported regression
git checkout def5678
npm install
npm run benchmark > results-def5678.txt
# Compare results
diff results-abc1234.txt results-def5678.txt
# Main development directory remains undisturbed
cd ~/projectIntegration Advantage: Worktree isolation prevents benchmark setup from contaminating development environment.
Technical Implications and Considerations
Commit Parent Relationships
Commits created in detached HEAD maintain correct parent pointers and are structurally identical to branch commits:
# In detached HEAD at commit A
git checkout abc1234
# Create commits B and C
git commit -am "Commit B"
git commit -am "Commit C"
# Inspect structure
git log --oneline --graph
# * xyz7890 (HEAD) Commit C
# * def5678 Commit B
# * abc1234 Original commit AStructural Validity: B and C form valid commit objects with proper parent linkage. They differ from branch commits only in lacking a branch reference—a metadata distinction, not a structural defect.
Garbage Collection Exposure
Unreferenced commits (those not reachable from branches, tags, or reflog) are subject to Git’s garbage collection:
# View garbage collection configuration
git config --get gc.reflogExpire
# Default: 90 days
# Check for unreachable objects
git fsck --unreachable
# Force immediate garbage collection (use cautiously)
git gc --prune=nowProtection Mechanism: Reflog provides a grace period. Even after leaving detached HEAD, your commits remain accessible via reflog for the configured expiration period (typically 90 days).
Recovery Window: If you realize you need detached commits after returning to a branch, you have substantial time to recover them before garbage collection.
Operational Best Practices
Use Modern Command Syntax
Git 2.23 introduced git switch to disambiguate operations that previously
overloaded git checkout:
# Explicit detachment intent
git switch --detach v2.0.0
# Branch creation without detachment
git switch -c new-feature
# Clearer than ambiguous checkout
git checkout v2.0.0 # Implicit detachmentRecommendation: Prefer git switch in scripts and documentation. Explicit
--detach flag communicates intent and prevents accidental detachment.
Detection and Awareness
Programmatically detect detached HEAD state in scripts:
# Check if on a branch (empty output indicates detached)
git branch --show-current
# Alternative using symbolic-ref
git symbolic-ref --short HEAD 2>/dev/null || echo "DETACHED HEAD"
# Exit code-based detection
if git symbolic-ref --short HEAD &>/dev/null; then
echo "On branch"
else
echo "Detached HEAD"
fiAutomation Integration: Build systems and deployment scripts should verify branch state before operations that assume branch context.
Visual Context Tools
Understanding detached HEAD position relative to branches:
# Graph showing HEAD position
git log --oneline --graph --all --decorate -10
# Detailed view
git log --oneline --graph --all --decorate --simplify-by-decorationOutput Interpretation: In graph output, (HEAD) without an accompanying
branch name indicates detachment. Nearby branch names show relative position in
commit history.
Common Misconceptions and Clarifications
Misconception 1: Detached HEAD Indicates Error
Reality: Detached HEAD is a legitimate operational mode for specific workflows. Git’s warning message is informational, not an error condition. The state is intentional and necessary for operations like bisect, historical inspection, and submodule management.
Misconception 2: Detached Commits Are Immediately Lost
Reality: Commits persist in Git’s object database and remain accessible via reflog for 30-90 days. You have ample opportunity to recover them by creating a branch reference before garbage collection occurs.
Misconception 3: Commit Creation is Prohibited
Reality: Git permits normal commit operations in detached HEAD. The distinction is that commits lack automatic branch reference tracking. You can commit freely and later decide whether to preserve work by creating a branch.
Misconception 4: Detached HEAD Corrupts Repository
Reality: Detached HEAD is a pointer state modification, not repository
corruption. The .git directory remains fully intact. Switching to any branch
immediately resolves detachment without any special recovery procedures.
Decision Framework: When to Create a Branch
Create a branch if:
- You intend to make commits worth preserving
- Changes might be useful for future reference or merging
- You’re beginning active development rather than read-only inspection
- Multiple developers might need access to this work
Remain detached if:
- Performing read-only historical inspection
- Running tests on specific commits
- Executing scripted workflows (bisect, CI/CD builds)
- Experimenting with disposable approaches
Configuration and Customization
Shell Prompt Integration
Display detached HEAD status in your shell prompt:
Bash:
# Add to ~/.bashrc
parse_git_branch() {
git symbolic-ref --short HEAD 2>/dev/null || echo "detached:$(git rev-parse --short HEAD)"
}
PS1='[\u@\h \W $(parse_git_branch)]\$ 'Zsh:
# Add to ~/.zshrc
autoload -Uz vcs_info
precmd() { vcs_info }
zstyle ':vcs_info:git:*' formats '%b'
setopt PROMPT_SUBST
PS1='%n@%m %1~ ${vcs_info_msg_0_}%# 'Git Configuration
Control warning behavior:
# Enable detailed warnings (default)
git config --global advice.detachedHead true
# Suppress warnings (not recommended)
git config --global advice.detachedHead falseSummary
Detached HEAD represents Git’s mechanism for working directly with commits independent of branch references. This state serves critical functions:
- Historical Inspection: Examining repository state at specific commits without branch contamination
- Experimental Development: Low-friction prototyping with simple abandonment option
- Reproducible Operations: Ensuring exact commit targeting for builds, tests, and deployments
- Automated Workflows: Supporting tools like bisect, rebase, and submodules
Conceptual Foundation: Git’s architecture separates commits (immutable snapshots) from references (mutable pointers). Branches are convenient labels; commits exist independently. Detached HEAD exposes this fundamental separation, allowing direct commit-level operations when branch semantics aren’t required.
Operational Safety: Understanding detached HEAD transforms it from a confusing warning into a purposeful tool. The reflog safety net provides recovery options, while clear operational patterns enable confident use of this powerful feature.
Integration: Detached HEAD isn’t an error state to avoid—it’s a feature to understand and employ strategically. Proper use enhances workflow flexibility while maintaining Git’s guarantee of data integrity and recoverability.
When Does Detached HEAD Occur?
Git enters detached HEAD state in several common scenarios:
1. Checking Out a Specific Commit
# Direct commit checkout
git checkout abc1234
# Checking out a tag
git checkout v2.0.0
# Relative reference
git checkout HEAD~3Use Case: Examining historical code state, reproducing bugs in old releases, or testing specific commits.
2. During Bisect Operations
git bisect start
git bisect bad # Current commit is broken
git bisect good v1.0.0 # v1.0.0 worked fine
# Git automatically checks out commits for testing—each in detached HEAD stateTechnical Rationale: Bisect needs to move through arbitrary commits without affecting branch structure.
3. In Worktrees
# Create worktree at specific commit
git worktree add --detach ../testing abc1234
# Worktrees checking out tags or commits
git worktree add ../release-test v2.0.0Why Detached: When examining specific snapshots without intent to continue development from that point.
4. During Interactive Rebase
git rebase -i HEAD~5
# During rebase, Git temporarily detaches HEAD while replaying commitsTemporary State: Git automatically reattaches HEAD when rebase completes successfully.
5. Submodule Updates
git submodule update
# Submodules are checked out at specific commits (detached HEAD by design)By Design: Submodules track specific commit hashes, not branches, ensuring reproducible builds.
Working in Detached HEAD State
Git’s Warning Message
When entering detached HEAD, Git displays:
Note: switching to 'abc1234'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
HEAD is now at abc1234 Implement user authenticationSafe Operations in Detached HEAD
Read-Only Inspection (Always Safe):
# View files
cat src/auth.py
# Run tests
npm test
# Check history
git log
# Compare with branches
git diff mainExperimental Commits (Safe if Intentional):
# Make changes
vim src/feature.py
# Commit normally
git add src/feature.py
git commit -m "Experimental approach"
# Continue experimenting
git commit -m "Another experimental commit"What Happens: Commits are created but exist in isolation—no branch reference points to them.
Recovering from Detached HEAD
Scenario 1: Discard Work (Return to Branch)
If you explored but made no commits or don’t want to keep them:
# Return to previous branch
git switch main
# Alternative
git checkout mainResult: Any commits made in detached state become unreferenced and will eventually be garbage collected (typically after ~30 days).
Scenario 2: Preserve Work (Create Branch)
If you made commits you want to keep:
Option A: Create branch immediately:
# While still in detached HEAD
git switch -c experimental-feature
# Now your commits are on a branch
git log
# Shows your detached HEAD commits on new branchOption B: Create branch after returning to main:
# You switched back to main but forgot to save detached commits
git switch main
# Find the lost commits
git reflog
# Output shows:
# abc1234 HEAD@{0}: checkout: moving from xyz7890 to main
# xyz7890 HEAD@{1}: commit: My experimental commit
# Create branch pointing to that commit
git branch experimental-feature xyz7890
# Verify branch contains your work
git log experimental-featureScenario 3: Already Switched Away (Recovery via Reflog)
Even after leaving detached HEAD, your commits remain accessible temporarily through reflog:
# View recent HEAD movements
git reflog
# Output:
# abc1234 HEAD@{0}: checkout: moving from def5678 to main
# def5678 HEAD@{1}: commit: Experimental change
# ghi9012 HEAD@{2}: commit: Another experiment
# jkl3456 HEAD@{3}: checkout: moving from main to jkl3456
# Recover by creating branch at that point
git branch recovered-work def5678
# Or cherry-pick specific commits
git cherry-pick def5678 ghi9012Time Window: Unreferenced commits persist in reflog for approximately 30-90
days (configurable via gc.reflogExpire).
Practical Use Cases for Detached HEAD
1. Safe Code Archaeology
Scenario: Investigating when a bug was introduced without disrupting current work.
# Jump to suspected problematic commit
git checkout abc1234
# Test the code
npm test
# If bug present, go further back
git checkout HEAD~5
# Test again
npm test
# When done investigating
git switch mainAdvantage: No branch pollution, no stash juggling, no risk of accidentally committing to wrong branch.
2. Release Verification
Scenario: QA needs to test the exact production release state.
# Check out tagged release
git checkout v2.1.0
# Run full test suite
npm install
npm run test:integration
# Verify deployment artifacts
npm run build
ls dist/
# Return to development
git switch developCritical: Detached HEAD ensures testing occurs on exact production snapshot, not accidentally including newer commits.
3. Experimental Prototyping
Scenario: Testing radical architectural changes without committing to a branch strategy.
# Start from stable commit
git checkout stable-release
# Enter detached HEAD
# Make experimental changes
vim src/architecture.py
git commit -am "Radical new approach"
# Test it
npm test
# Decision point:
# A) Works well → create branch: git switch -c new-architecture
# B) Failed → abandon: git switch mainBenefit: Low-friction experimentation. If approach fails, simply abandon without branch cleanup.
4. Build Artifact Generation
Scenario: CI/CD systems often check out specific commit hashes for reproducible builds.
# CI script checks out exact commit
git checkout $COMMIT_SHA
# Build from exact snapshot
npm run build
# Deploy artifacts
./deploy.sh dist/Why Detached: Branch names can move; commit SHAs are immutable. Detached HEAD enforces build reproducibility.
Technical Implications of Detached HEAD
Commit Parent Relationships
Commits created in detached HEAD have normal parent relationships—they’re not malformed:
# In detached HEAD at commit A
git checkout abc1234
# Make commit B
echo "change" >> file.txt
git commit -am "Experimental commit B"
# Make commit C
echo "more" >> file.txt
git commit -am "Experimental commit C"
# View structure
git log --oneline --graph
# Output:
# * xyz7890 (HEAD) Experimental commit C
# * def5678 Experimental commit B
# * abc1234 Original commit AStructure is Valid: B and C are proper commits with correct parent pointers. They lack only a branch reference.
Garbage Collection Behavior
Unreferenced commits (those not reachable from any branch, tag, or reflog) are subject to garbage collection:
# View garbage collection schedule
git config --get gc.reflogExpire
# Default: 90 days
# Immediate GC (dangerous if you have unreferenced commits)
git gc --prune=now
# Check for unreachable objects
git fsck --unreachableSafety Net: Reflog extends the lifetime of detached HEAD commits, but they’re not permanent unless referenced by a branch or tag.
Avoiding Unintentional Detached HEAD
Use Modern Commands
Git 2.23+ introduced git switch and git restore to reduce confusion:
# Old way (ambiguous)
git checkout v2.0.0 # Detaches HEAD
# Explicit intent
git switch --detach v2.0.0 # Clearly indicates detachment
# Branch creation is separate
git switch -c new-feature # Never detachesConfigure Warnings
Increase awareness when entering detached HEAD:
# Add to global Git config
git config --global advice.detachedHead trueCommon Misconceptions
Myth 1: “Detached HEAD is an Error State”
Reality: Detached HEAD is a legitimate, intentional mode for specific workflows. Git’s warning is informational, not an error.
Myth 2: “Commits Made in Detached HEAD are Lost Immediately”
Reality: Commits persist and are accessible via reflog for 30-90 days. You have ample time to recover them.
Myth 3: “You Can’t Create Commits in Detached HEAD”
Reality: Committing works normally. The difference is commits aren’t attached to a branch—yet. You can attach them later.
Myth 4: “Detached HEAD Breaks the Repository”
Reality: Detached HEAD is a pointer state, not a repository corruption. Switching back to any branch immediately resolves it.
Decision Framework: Should I Create a Branch?
Create a branch if:
- You plan to make commits you want to keep
- Changes might be useful for others or for later merging
- You’re starting active development work
Stay detached if:
- Just inspecting historical state (read-only)
- Running quick tests on old commits
- Experimenting with approaches you’ll likely discard
- Following a scripted workflow (bisect, submodule updates)
Pro Tips
Quickly Check if Detached
# Show current branch (displays nothing if detached)
git branch --show-current
# Alternative using git symbolic-ref
git symbolic-ref --short HEAD 2>/dev/null || echo "DETACHED"Automate Branch Creation from Detached State
# Shell alias for quick branch creation
git config --global alias.save '!git switch -c'
# Usage when in detached HEAD
git save recovered-experimentVisualize Where You Are
# See detached HEAD in context
git log --oneline --graph --all -10
# HEAD marked with (HEAD) but no branch nameSummary
Detached HEAD is Git’s mechanism for working with specific commits independent of branch references. It enables:
- Safe historical inspection without branch impact
- Low-friction experimentation with easy abandonment
- Precise commit targeting for reproducible operations
- Temporary work states during complex operations (rebase, bisect)
Understanding detached HEAD transforms it from a confusing error message into a powerful tool for flexible version control workflows. The key insight: commits don’t require branches to exist—branches are simply convenient labels pointing to commits. Detached HEAD removes that label temporarily, allowing direct commit-level work.