Skip to content
GitTree
History and recovery

Squash commits

Squashing combines several commits into one, like a fixup or squash in git rebase -i. In GitTree every squash opens the Squash dialog first: it shows the commits that fold, the result, the message and who gets credit, and nothing changes until you confirm. Your uncommitted work is never touched, and Undo puts the commits back.

FreeUpdated

Works in GitTree Free: every local Git feature, once you are signed in.

On this page
  1. Before you start
  2. Where to find it
  3. Steps
  4. Expected result
  5. Ways to squash
  6. Commits you already pushed
  7. Fixup commits for later
  8. Squash merges keep their authors
  9. Settings
  10. If something goes wrong
  11. Questions
  12. Related

Before you start

  • The commits are on the branch you have checked out, in one unbroken line. A selection cannot hold a merge commit; Squash Branch… can.
  • Squashed commits and every commit above them get new ids. If you already pushed them, you will need a force push afterwards; history that another remote branch contains cannot be squashed here.

Where to find it

  • Select two or more commits in the graph (Shift-click for a range), right-click: Squash Commits….
  • Right-click one commit: Edit History › Squash into Parent… or Fixup into Parent….
  • Right-click the checked-out branch in the graph or the left panel: Squash Branch….
  • Hold Alt (⌥ on a Mac) and drag a commit onto the commit right above or below it.
  • Right-click a commit: Edit History › Create Fixup Commit… to commit what is staged as a fixup for it.
  • Every one of these is also in the command palette and on the Squash card of the Feature Guide.
ActionmacOSWindows and Linux
Squash Commits… on the selection⌥SAlt+S
Squash into Parent… for the selected commit⌥QAlt+Q
Squash Branch… for the checked-out branch⌥⇧BAlt+Shift+B
Undo the squash⌘ZCtrl+Z

Steps

  1. Open the Squash dialog

    Use any entry above. The dialog is named after what you squash, for example Squash 3 Commits, Squash a1b2c3d into Its Parent or Squash Branch feature/login. Its summary line reads like “3 commits become 1 · 12 files · +240 −31 · keeps Ada’s authorship”.

  2. Check the commits that fold

    Commits that fold lists them oldest first under the Result: one commit written by the author of the oldest one. For Squash Branch…, Base: shows where the branch left its base; Change… lets you type another branch, tag or commit, and the plan is made again.

  3. Choose the message

    Under Start the message from, pick Combine Messages, Oldest Message, Newest Message, List of Commits or Write My Own, then edit the text as you like. A summary line is required.

  4. Keep the other authors credited

    When other people wrote some of the commits, Credit the other authors (Co-authored-by) adds a Co-authored-by line for each of them. The lines it adds are listed under it; untick it to leave them out.

  5. Read what else changes, then squash

    What else changes says how many commits above get new ids (their changes stay the same) and which other branches or tags keep the old commits. Press the confirm button, such as Squash 3 Commits or Squash into Parent.

Expected result

GitTree says, for example, 3 commits squashed into a1b2c3d. with an Undo button, and the graph shows one commit where there were several.

Your staged and unstaged changes and untracked files are exactly as they were: the squash never touches the working tree.

Ways to squash

What each squash folds
CommandWhat folds
Squash Commits…The commits you selected, two or more next to each other on the checked-out branch.
Squash into Parent…One commit into the commit below it.
Fixup into Parent…The same, keeping only the parent’s message (like fixup in git rebase -i).
Squash Branch…Every commit of the branch since it left its base, merges included, into one commit on that base.
Alt-dragThe dragged commit and the neighbour you drop it on. The cue Drop to squash … shows where you can drop; Esc cancels.

Commits you already pushed

If the branch’s upstream has the commits, the dialog says so and asks you to tick I will force push … after squashing before it squashes. Afterwards the message offers Force Push…, which replaces the remote branch only if it is still where you last saw it (force push).

Fixup commits for later

To fix an older commit without rewriting anything now, stage the change and choose Create Fixup Commit… on that commit. Pick Fixup (keeps its message), Squash (adds a note) or Amend (replaces its message with the New message). GitTree commits a fixup!, squash! or amend! commit; an interactive rebase with Arrange fixup!, squash! and amend! commits on folds it in.

Squash merges keep their authors

When you merge a branch with Squash into staged changes (no commit), an empty commit box gets a message listing the commits it brings, with Co-authored-by lines for their authors. A message you already wrote is kept.

Settings

In Preferences › General, Squash: starting message picks the message the dialog starts with, and Squash: credit co-authors sets whether credit starts ticked. Each squash can still change both.

If something goes wrong

“The commits are not next to each other. Select an unbroken run.”

Select commits that follow one another on the checked-out branch, or use Squash Branch… for the whole branch.

“A merge commit would fold. Squash Branch… folds merges; a selection cannot.”

Use Squash Branch…, or an interactive rebase to choose commit by commit.

“… contains these commits: they are shared history and cannot be squashed here.”

Another remote branch has them. Leave them as they are, or agree with your team before rewriting shared history from the command line.

The squash stops with an error and a Review Again button

Something changed the branch while the dialog was open, so nothing was squashed. Press Review Again to see the new plan, then squash again.

Questions

How do I undo a squash?

Press Undo in the message or the toolbar. GitTree kept the old commits under refs/ogt/trash before it moved the branch, so they come back exactly as they were.

Whose name is on the squashed commit?

The author of the oldest commit that folds, with its date; you are the committer. Turn on Credit the other authors (Co-authored-by) to keep everyone else credited.

Does squashing run my commit hooks or touch my working files?

No. GitTree writes the new commits directly, the way git rebase does internally, and never changes the index or the files in your working tree. It signs them when your Git configuration asks for signed commits.