Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Configuration Options

rebase.* settings

Reference for rebase.* settings: rebase.autoSquash, autoStash, updateRefs, missingCommitsCheck, instructionFormat and rebaseMerges, with runnable examples.

The rebase.* settings change how git rebase behaves by default so you do not have to repeat flags. Three are worth knowing by heart: rebase.autoSquash (apply fixup! and squash! commits automatically), rebase.autoStash (save and restore uncommitted changes around the rebase) and rebase.updateRefs (move other branches that point into the rebased range).

Terminal
git config --global rebase.autoSquash true
git config --global rebase.autoStash true
git config --global rebase.updateRefs true

Try it

Bash autoSquash with fixup commits

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash autoStash and updateRefs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git config rebase.autoSquash (true | false)
git config rebase.autoStash (true | false)
git config rebase.updateRefs (true | false)
git config rebase.missingCommitsCheck (ignore | warn | error)
git config rebase.instructionFormat <format>
git config rebase.rebaseMerges (true | false | rebase-cousins | no-rebase-cousins)
git config rebase.abbreviateCommands (true | false)
git config rebase.forkPoint (true | false)
git config rebase.stat (true | false)
git config rebase.backend (merge | apply)
Name Description
rebase.autoSquash In interactive rebases, move fixup!/squash!/amend! commits next to their target and mark them automatically.
rebase.autoStash Stash uncommitted changes before the rebase and pop them afterwards (same as --autostash).
rebase.updateRefs Branches pointing at rebased commits are moved too, which makes stacked branches painless (Git 2.38+).
rebase.missingCommitsCheck What to do when you delete a line from the todo list: ignore (default), warn or error.
rebase.instructionFormat git log format used for each todo line; %s is the default.
rebase.rebaseMerges Keep merge commits instead of flattening them (same as --rebase-merges).
rebase.abbreviateCommands Write p, f, s instead of pick, fixup, squash in the todo list.
rebase.forkPoint Use the reflog fork point as the default upstream base; false uses the plain upstream tip.
rebase.stat Show a diffstat of what changed upstream after rebasing.

Errors: a rebase with uncommitted changes and no auto-stash fails with error: cannot rebase: You have unstaged changes.. With rebase.missingCommitsCheck=error, removing a pick line aborts with the list of dropped commits.

Usage notes

  • autoSquash pairs with git commit --fixup <commit>. You commit the correction now and let the next git rebase -i fold it into the right commit. It only has an effect in interactive mode.
  • To squash without opening an editor, set GIT_SEQUENCE_EDITOR=: for that command, as the first example does.
  • autoStash can conflict. If the stash does not apply cleanly after the rebase, Git keeps it and tells you; resolve then with git stash pop.
  • updateRefs only moves branches that point at commits inside the rebased range, and not the current branch's remote-tracking ref. Check with git log --decorate.
  • Backend: the merge backend is the default; rebase.backend=apply is only needed to get old git am-style behavior and is deprecated.
  • Interaction with pull: git pull --rebase honors these settings; see pull.rebase.
  • Rewriting shared history is still dangerous, no matter how convenient the defaults are.