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

Use binary search to identify the commit that introduced a bug or behavior change.

Start bisect with good and bad revisions

Initialize bisect and mark boundaries.

bashANYgitbisectdebugging
bash
git bisect start <bad_commit> <good_commit>

Fastest way to launch a bisect session when both endpoints are already known.

Mark current commit as good

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

bashANYgitbisectdebugging
bash
git bisect good

Bisect uses your good/bad classification to narrow the search range.

Mark current commit as bad

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

bashANYgitbisectdebugging
bash
git bisect bad

Each classification halves the remaining search space.

Automate bisect with a test script

Let Git drive bisect using a command exit code.

bashANYgitbisectautomationdebugging
bash
git bisect run ./test-regression.sh

Powerful for deterministic regressions where a test script can return success/failure automatically.

End bisect session

Return the repository to the original branch state.

bashANYgitbisectcleanup
bash
git bisect reset

Always reset at the end so you are no longer on a temporary bisect-selected revision.

Skip an untestable bisect revision

Tell bisect to avoid the current commit.

bashANYgitbisectskip
bash
git bisect skip

Useful when a revision does not build or cannot be meaningfully tested.

Cherry-pick Workflows

Copy selected commits across branches safely.

Cherry-pick one commit

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

bashANYgitcherry-pickworkflow
bash
git cherry-pick <commit_sha>

Common for backports, hotfixes, or selectively transferring changes across branches.

Cherry-pick multiple commits

Apply several explicit commits in sequence.

bashANYgitcherry-pickworkflow
bash
git cherry-pick <sha1> <sha2> <sha3>

Useful when the commits are not contiguous in history but all need to be transferred.

Cherry-pick a contiguous range

Apply a range of commits inclusively.

bashANYgitcherry-pickrange
bash
git cherry-pick <start_sha>^..<end_sha>

Common syntax for selecting a continuous segment of commits.

Cherry-pick a merge commit

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

bashANYgitcherry-pickmergemainline
bash
git cherry-pick -m 1 <merge_commit_sha>

Like revert of a merge, cherry-picking a merge requires selecting the mainline parent.

Continue cherry-pick after conflicts

Resume a paused cherry-pick sequence.

bashANYgitcherry-pickcontinueconflicts
bash
git cherry-pick --continue

Cherry-pick uses the same style of conflict lifecycle as rebase and revert.

Abort cherry-pick

Cancel the current cherry-pick operation.

bashANYgitcherry-pickabort
bash
git cherry-pick --abort

Use when conflicts are too messy or you decide not to port the change.

Submodule Workflows

Initialize, update, sync, and maintain submodule-based repositories.

Show submodule status

Inspect recorded commit pointers and checkout state.

bashANYgitsubmodulestatus
bash
git submodule status --recursive

Useful for understanding whether submodules are initialized, detached, or out of sync.

Clone including submodules

Clone a repository and initialize its submodules immediately.

bashANYgitsubmoduleclone
bash
git clone --recurse-submodules <repo_url>

Saves an extra initialization step after clone for repositories that depend on submodules.

Update submodules to their tracked remote branches

Fetch and move submodules according to configured tracking branches.

bashANYgitsubmoduleupdateremote
bash
git submodule update --remote --recursive

Useful when submodules are meant to follow upstream branch tips rather than staying pinned until manually updated.

Run a command in every submodule

Execute a shell command across all submodules.

bashANYgitsubmoduleforeach
bash
git submodule foreach --recursive 'git status --short'

Great for auditing or applying common operations across many submodules.

Sync submodule URLs

Update local submodule config from `.gitmodules`.

bashANYgitsubmodulesync
bash
git submodule sync --recursive

Important after changing submodule remote URLs in `.gitmodules`.

Remove a submodule carefully

Delete submodule entry and tracked path.

bashANYgitsubmoduleremove
bash
git rm path/to/submodule

Modern Git handles most removal cleanup well, but you should still review `.gitmodules` and config state afterward.

Recommended next

No recommendations yet.