Git Bisect, Cherry-pick, and Submodule Cheat Sheet

Advanced workflows for regression hunting, selective commit transfer, and repository dependency management.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Bisect Workflows
Start bisect with good and bad revisions
git bisect start <bad_commit> <good_commit>

# Initialize bisect and mark boundaries.

Mark current commit as good
git bisect good

# Tell bisect the current checked-out commit does not contain the bug.

Mark current commit as bad
git bisect bad

# Tell bisect the current checked-out commit contains the bug.

Automate bisect with a test script
git bisect run ./test-regression.sh

# Let Git drive bisect using a command exit code.

End bisect session
git bisect reset

# Return the repository to the original branch state.

Skip an untestable bisect revision
git bisect skip

# Tell bisect to avoid the current commit.

## Cherry-pick Workflows
Cherry-pick one commit
git cherry-pick <commit_sha>

# Apply the changes introduced by one commit onto the current branch.

Cherry-pick multiple commits
git cherry-pick <sha1> <sha2> <sha3>

# Apply several explicit commits in sequence.

Cherry-pick a contiguous range
git cherry-pick <start_sha>^..<end_sha>

# Apply a range of commits inclusively.

Cherry-pick a merge commit
git cherry-pick -m 1 <merge_commit_sha>

# Apply changes from a merge commit relative to a chosen parent.

Continue cherry-pick after conflicts
git cherry-pick --continue

# Resume a paused cherry-pick sequence.

Abort cherry-pick
git cherry-pick --abort

# Cancel the current cherry-pick operation.

## Submodule Workflows
Show submodule status
git submodule status --recursive

# Inspect recorded commit pointers and checkout state.

Clone including submodules
git clone --recurse-submodules <repo_url>

# Clone a repository and initialize its submodules immediately.

Update submodules to their tracked remote branches
git submodule update --remote --recursive

# Fetch and move submodules according to configured tracking branches.

Run a command in every submodule
git submodule foreach --recursive 'git status --short'

# Execute a shell command across all submodules.

Sync submodule URLs
git submodule sync --recursive

# Update local submodule config from `.gitmodules`.

Remove a submodule carefully
git rm path/to/submodule

# Delete submodule entry and tracked path.

Recommended next

No recommendations yet.