Graph
Multiple selection
8 min read
Selecting several commits at once is good for two things: seeing what changed between them (the diff between two commits or the combined diff of a sequence) and acting on all of them together (combining them into a single commit, dropping, cherry-picking, reverting or interactive rebase). This page explains how to select, what the right panel shows and which actions apply to the selection.
In the graph, with the mouse or the keyboard.
| To | Do |
|---|---|
| Start a selection | Click a commit (it's the anchor). |
| Add or remove a commit | Ctrl+click it. |
| Select a range | Shift+click the other end: all the commits between the anchor and it are included, in graph order. |
| Extend the range from the keyboard | Shift+↓ / Shift+↑. |
| Go back to a single-commit selection | Esc, the clear link in the footer, the right panel's "Clear selection (Esc)" X or a simple click on a commit. |
With two or more commits selected, the graph footer shows "3 commits selected" and the clear link.
- The WIP row, the WIP rows of other worktrees and the stashes aren't part of the selection: the actions are for commits. A Shift+click that passes over them skips them.
- Shift+click with no commit selected before becomes a simple selection.
- If you Ctrl+click until only one commit is left, the selection becomes simple again.
- After a rebase, the selected commits get new SHAs; the ones that no longer exist leave the selection.
With several commits selected, the right panel stops showing a single commit and shows the selection diff instead:
- two commits: the diff between them, from oldest to newest;
- consecutive commits (each one is the first parent of the next): the combined diff, from the parent of the oldest to the newest. It's the same as applying all the commits at once;
- commits that aren't in sequence: their sum doesn't make a single diff; the panel offers to compare the oldest with the newest.
Click a file in the list to open its diff in the central area.
In the right panel, as soon as there are two or more commits selected in the graph.
| Element | What it does |
|---|---|
| Title | "Diff between 2 commits", "Combined diff of 3 commits", "Diff between the ends of 4 commits" or "4 commits selected" (with no diff chosen). |
| What to compare › Between the two | "The differences from the oldest commit to the newest". Default with two commits. |
| What to compare › Combined | "All the changes of the selected commits together, as if they were a single commit". Default with three or more consecutive commits; it also appears with two consecutive commits. |
| from / to | The two sides of the diff. Without a parent (the repository's first commit), the "from" side appears as "(empty)". |
| ⇅ Swap sides | "Reverses the diff: from the newest to the oldest". |
| Open comparison | "Opens the full comparison in the center area, with the commits on each side". See Comparing revisions. |
| Combined note | "Includes the changes of 3 commits, from a1b2c3d to d4e5f6a." |
| File list | "5 files changed"; with both sides equal, "Both commits have the same files." |
With commits out of sequence, the panel says: "The selected commits aren't in sequence, so their sum isn't a single diff. Select consecutive commits (Shift+click) or compare only the ends." The Compare the oldest with the newest button turns on Between the two mode.
- Shift+click to select three consecutive commits of
feature/login. - The panel shows "Combined diff of 3 commits" and the changed files.
- Click a file to see its diff.
- To see only what changed between the first and the last commit without adding them up, select only those two with Ctrl+click and use Between the two.
- Click ⇅ Swap sides to read the diff backwards (useful to see what would be undone).
It only reads. The file list is equivalent to:
# Between the two
git diff --name-status -M a1b2c3d f7e8d9c --
# Combined (from the parent of the oldest to the newest)
git diff --name-status -M a1b2c3d^ d4e5f6a --
- The selection diff doesn't include uncommitted changes.
- To compare whole branches (what goes into a merge), use Compare with… in the branch menu. See Comparing revisions.
Right-click any commit that is part of the selection to open the selection menu. Each action is only enabled when it applies to all the chosen commits; when it doesn't, the item appears gray with the reason, for example "Squash 3 commits… — the commits aren't adjacent".
Right-click a selected commit (with two or more selected). Right-clicking a commit outside the selection opens that commit's menu and clears the selection.
| Item | What it does | When it's disabled | Page |
|---|---|---|---|
| Squash 3 commits… | Combines the commits into one, with the message you edit (Summary and Description, already filled in with the combined messages). | Commits off the current branch, not adjacent, with a merge in the range, with a stash or with an operation in progress. | Squash |
| Drop 3 commits… (in red) | Removes the commits from the current branch's history, with confirmation. | Commits off the current branch, a merge in the range, a stash or an operation in progress. | Edit message, drop and move commits |
| Cherry-pick 3 commits | Applies the commits on the current branch, from oldest to newest, with a conflict preview first. | Selection with a merge, with a stash, with commits that are already on the current branch, or an operation in progress. | Cherry-pick |
| Revert 3 commits | Creates commits that undo the chosen ones, from newest to oldest, with a conflict preview first. | Selection with a merge, with a stash or an operation in progress. | Revert |
| Cherry-pick into another worktree › | Cherry-picks the commits onto another worktree's branch. Only appears with other worktrees. | Selection with a merge or a stash (the item disappears). | Moving changes and commits between worktrees |
| Move to another worktree › | Takes the commits to another worktree and removes them from here. | The commits aren't the ones at the top of the current branch, in sequence. | Moving changes and commits between worktrees |
| Interactive rebase of 3 commits… | Opens the interactive rebase from the oldest selected commit up to HEAD, with the selected ones highlighted. | Commits off the current branch, a merge in the range, a stash or an operation in progress. | Interactive rebase |
| Compare a1b2c3d with d4e5f6a | Opens the comparison of the oldest with the newest in the central area. | — | Comparing revisions |
| Team commands › / My commands › | Custom commands defined for the selection (where: [selection]). They only appear if there are any. | — | Custom commands |
| Copy the 3 SHAs | Copies the full SHAs, one per line, from newest to oldest (as in the graph). Notice: "3 SHAs copied". | — | — |
| Clear selection | Goes back to a single-commit selection (the newest one in the selection). | — | — |
The reasons that can appear after the "—":
| Reason | What it means |
|---|---|
| "an operation is in progress" | There's a stopped merge, rebase, cherry-pick or revert. Finish or abort it first. |
| "the selection includes a stash" | A stash isn't a commit in the history. |
| "some commits aren't on main" | Rewriting only applies to commits on the current branch's line (main is the example). |
| "there's a merge in the range" | Between HEAD and the oldest chosen commit there's a merge. |
| "the selection includes a merge" | Cherry-picking and reverting merges isn't done from here. |
| "the commits aren't adjacent" | Squash needs commits in sequence. |
| "some commits are already on main" | The current branch already contains some of the commits: the cherry-pick wouldn't add anything. |
Combine three commits into one
- On the current branch, Shift+click to select the three consecutive commits.
- Right-click one of them › Squash 3 commits….
- In the Squash 3 commits dialog ("The 3 commits become one, with all of their changes and the message below."), adjust the Summary and the Description.
- Click Squash commits. When it's done: "Squashed 3 commits into one."
Bring three commits to the current branch
- Select the commits on another branch with Ctrl+click.
- Right-click › Cherry-pick 3 commits. First, the app predicts conflicts.
- When it's done: "Cherry-picked 3 commits."
# Cherry-pick (from oldest to newest)
git cherry-pick a1b2c3d b2c3d4e c3d4e5f
# Revert (from newest to oldest)
git revert --no-edit c3d4e5f b2c3d4e a1b2c3d
Squash, drop and interactive rebase rewrite the current branch starting from the oldest chosen commit, like the interactive rebase.
Each action is a single operation in the undo history: Ctrl+Z undoes the whole squash ("Squash 3 commits"), drop ("Drop 3 commits"), cherry-pick ("Cherry-pick 3 commits") or revert ("Revert 3 commits"). An operation that stopped at a conflict doesn't go into the undo history until it finishes: use Abort. See Undo and redo.
- Squash, drop and interactive rebase rewrite history. If any of the commits is already on the remote, the dialog warns you: "This rewrites history, and 2 of the commits involved are already on the remote: you'll need to force push afterwards, and anyone who already pulled those commits will have to adjust." See Force push.
- "The selection is no longer on the current branch. Refresh the graph and select again.": the branch changed since you selected (a fetch, a commit somewhere else).
- If the cherry-pick or the revert stops at a conflict, resolve it in the conflict editor and click Continue. See Stopped merge, rebase, cherry-pick and revert.
The conflict preview before cherry-pick and revert is described in Predicting conflicts before an operation.
With several commits selected, drag any one of them onto a local branch label: the app builds the plan to cherry-pick all the selected commits onto that branch, without needing a checkout. For a rebase by dragging, drag a single commit. See Dragging branches and commits.
- When you drag several commits onto another row of the graph, the label next to the cursor says "3 commits → to rebase, drag a single commit".
- The drag starts with the left button, without Ctrl or Shift (with them, the click keeps changing the selection).