Compare and reset

Three things you do with commits on the History tab beyond reading them. Compare shows what one branch, tag or commit changed against another, as a list of commits and a diff of every file. Reset moves the current branch to a commit, keeping or discarding the changes, with undo. Checking out a commit puts you on it without a branch, to look around or build an old version.

Where to find it

  • Command palette › History › Compare branches or tags…, or ⌘-click a second commit on History to compare it with the selected one.
  • History tab › commit menu: Reset branch to here… and Check out hash….

Compare

The Compare sheet

"See what changed between two branches, tags or commits. In History, ⌘-click a second commit to compare it with the selected one."

FieldDetail
Base, HeadEach takes a branch, tag or commit; the placeholder is "Branch, tag or commit". Base starts as the default branch, or the current branch's upstream, and Head as the current branch. Swap base and head exchanges them.
ShowSince they split: "What head changed since it split from base (base...head)". Every difference: "Every difference between base and head (base..head)". Since they split is the default.

Compare, or ⏎, opens the comparison; with an end missing the error reads "Type a branch, tag or commit for both ends."

⌘-clicking a commit on History skips the sheet: the older of the two commits becomes the base and the newer the head.

The comparison

The comparison takes over the History tab in the same layout as a commit review. The bar shows base ... head (or base .. head for Every difference), a Swap button, the Show choice as a segmented control, the count and line totals ("N files"), Change… to reopen the sheet, and a reminder that [ and ] move between files.

The rail on the left lists the commits between the two ends: "N commits on head since it split from base", or for Every difference "N commits only on head, M only on base", marked + and − by side; "No commits on head that aren't on base" when there are none. The list is folded when it is longer than 30 commits, and reads "Showing the newest N." when it is cut. Clicking a commit closes the comparison and selects it in History. When the two ends have no common ancestor the rail notes "These share no history, so this compares them directly."

Under the rail, the file tree and the diffs work as in a commit review: filter the files, step through them, read every diff in one scroll, and open Blame or History for a file as of the head. While it loads the view reads "Comparing…"; with nothing to show, "No differences. head has the same files as where it split from base." esc or the History button at the top left goes back to the list. See Commit graph and search for the review layout and Diffs for the diff itself.

Reset

Reset branch to here… on a commit's menu moves the current branch to that commit. It is off on the commit the branch is already at. While HEAD is detached the item names the short hash instead of a branch, and the reset moves HEAD.

The Reset sheet

The sheet is titled "Reset branch to hash" and starts with the commit's summary and what the move means: "branch moves back N commits.", "branch moves forward N commits.", or "branch moves to another line of history: N commits leave it and M arrive." Then: "You can undo a reset."

Reset modeWhat it doesBranchStagedFiles
Soft: keep the changes staged"Undo the commits but keep their changes ready to commit again. Good for squashing or rewording."Moves to hashKeeps the changesUnchanged
Mixed: keep the changes, unstaged"Undo the commits and unstage everything, so you can choose what to commit again." The default.Moves to hashChanges unstagedUnchanged
Hard: discard the changes"Throw away the commits’ changes and uncommitted work in tracked files. Untracked files stay."Moves to hashClearedMatch hash

The button reads Reset branch, or Reset branch and discard for a hard reset. ⏎ does the same.

A hard reset with uncommitted changes

When tracked files have uncommitted changes, the Hard option warns: "N files have uncommitted changes. They’re stashed before the reset, and Undo brings them back." Pressing the button asks "Stash your changes and reset?": "N files have uncommitted changes, which a hard reset would throw away. They're stashed first, then branch resets to hash. Undo moves branch back and brings the changes back." The answers are Cancel and Stash and reset. The stash is an ordinary one, listed under Stashes in the sidebar.

After the reset

The toast reads "Reset branch to hash." followed by what became of the changes: "Changes from the commits it left are staged.", "Changes from the commits it left are in your files, unstaged." or "Your files match it.", and after a stash "Your uncommitted changes are in Stashes; Undo brings them back." Undo moves the branch back to where it was and, if the reset stashed your changes, pops that stash. See Committing for how undo works.

Checking out a commit

Check out hash… on a commit's menu asks "Check out hash?": "You'll be on hash itself, not on a branch (a detached HEAD): good for looking around or building an old version. To keep commits you make there, create a branch. Uncommitted changes come with you." The answers are Cancel and Check out hash.

If leaving your current position would strand commits that no branch contains, Mergepond asks instead "Leave N commits behind?": "HEAD has N commits that no branch contains. Checking out hash leaves them with no name, so they're hard to find again. Create a branch for them first." The answers are Check out anyway and Create branch first, which opens the New branch sheet.

The toast reads "Checked out hash. You're not on a branch; create one here to keep commits you make." The toolbar then shows the Detached at hash chip and a Create branch here button. See Branches and remotes.

Free and Pro

Compare, reset and checking out a commit work the same on Free and Pro.