Reference

Git

Inspect, save, combine and recover work with clear command effects.

Scope and conventions

Modern Git CLI, including switch and restore (Git 2.23+). Independent examples use illustrative paths and branch names. Inspect status and diffs before changing files or history. Commands below are reference material, not executed by this guide.

Combine changes

Integrate another branch

Git

merge combines history. It may fast-forward, create a merge commit, or stop with conflicts. --no-ff requests a merge commit even when a fast-forward is possible.

Fragment

Git · Integrate another branch
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
git switch feature/input
git merge main

Inspect the combined behavior, not just whether Git completed.

Resolve a stopped merge

Git

Conflict markers delimit competing text. Edit the intended result, stage resolved files and continue. git status describes the active operation.

Fragment

Git · Resolve a stopped merge
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
git status
# Edit and verify each conflicted file.
git add -- src/main.ts
git merge --continue

A file can contain no markers and still have the wrong behavior.

Abort an in-progress integration

Git

Use the abort command for the active operation. Starting with a clean workspace makes recovery more predictable.

Fragment

Git · Abort an in-progress integration
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
git merge --abort
# Or, during a rebase:
git rebase --abort

These are alternatives, not commands to run in sequence.

Replay commits onto a new base

Git

rebase recreates commits on a new base, changing their identities. Resolve each stop, stage it, then continue.

Fragment

Git · Replay commits onto a new base
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
git rebase main
# At a conflict, edit and stage, then:
git rebase --continue

Rebase is a history-editing workflow; preserve branches others are using.

Apply a selected commit

Git

cherry-pick applies a commit’s change on the current branch as a new commit. It can conflict and does not merge the source branch’s complete history.

Fragment

Git · Apply a selected commit
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
git cherry-pick COMMIT_ID

Replace COMMIT_ID with the inspected commit hash.

Reorder or combine unpublished commits

Git

Interactive rebase opens a todo list of commits to replay. pick keeps one; reword changes its message; fixup folds its change into an earlier commit without keeping its message.

Fragment

Git · Reorder or combine unpublished commits
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
git rebase -i HEAD~3
# Edit the todo list, then save.
# At a stop, inspect git status before continuing.

Commit identities change; coordinate before rewriting shared history. Keep a recoverable branch/ref while learning.