STG-REBASE(1)

πŸ’… STG-REBASE(1) β€” the StGit manual, bestie edition πŸŽ€

Okay so this is stg-rebase, part of the StGit manual, and it is literally the glow-up command for your stack. Let's get into it πŸ¦‹


✨ NAME ✨

stg-rebase β€” move the stack base to another point in history. Yes queen, we're relocating the whole foundation πŸ‘‘


🌸 SYNOPSIS 🌸

stg rebase [OPTIONS] [committish]

πŸ’– DESCRIPTION πŸ’–

So here's the tea β˜•: stg rebase pops all the patches off your current stack, moves the stack base to the new base you give it, and then pushes all those patches back on. It's giving "moving house but all your furniture comes with you" 🚚✨

Sometimes merge conflicts show up while the patches are being pushed back onto the stack. No panic, it happens πŸ’€ If that goes down, resolve the conflicts and then continue the rebase with this little sequence:

stg add --update
stg refresh
stg goto top-patch

Or, if you'd rather just skip the conflicting patch entirely:

stg undo --hard
stg push next-patch..top-patch

πŸ’… OPTIONS πŸ’…

  • -i, --interactive β€” interactively manipulate patches in the editor. You're the main character, you make the calls ✨
  • -n, --nopush β€” do not push back the patches after rebasing. Just... leave them off. Lowkey unhinged but valid πŸ™ˆ
  • -m, --merged β€” check for patches that may have been merged upstream πŸ‘€

When pushing back patches, each patch gets checked to see if its changes already exist in the new stack base. If a patch's changes are detected as having been merged, the patch will still exist in the stack, but it becomes empty after the rebase operation. Iconic, honestly β€” still there, just vibing with no content 🫢

  • --committer-date-is-author-date β€” instead of using the current time as the committer date, use the author date of the commit as the committer date. Time travel but make it git β°πŸ’«
  • --autostash β€” automatically create a temporary stash before the operation begins, and apply it after the operation completes. This allows a rebase to be performed on a dirty work tree 🧼✨
Heads up though: the final stash application may result in non-trivial conflicts. Not me warning you in advance 😭
  • --conflicts[=<policy>] β€” set it to either "allow" or "disallow" for pushing a patch with conflicts πŸ₯Š

Using --conflicts=allow (or just --conflicts) allows pushing a patch that may result in unresolved merge conflicts. The patch will be pushed and files with conflicts will be left with conflict markers to be resolved manually; or the operation undone with stg undo --hard. This is the default behavior and also corresponds to the "stgit.push.allow-conflicts" variable being set to "true". Chaos mode: enabled πŸ’€πŸ”₯

Using --conflicts=disallow disallows pushing any patch that would result in merge conflicts. The operation will stop on the last patch that can be pushed without conflicts. This behavior can be configured by setting "stgit.push.allow-conflicts" to "false". Peaceful mode: also enabled 🌈

  • -x <cmd>, --exec=<cmd> β€” execute the given shell command after each patch is successfully applied during the rebase operation. If the command fails (exits with non-zero status), the entire transaction is rolled back and no patches remain applied ⚑

This option may be specified multiple times to run multiple commands in sequence after each patch. Stack 'em up πŸŽ€

This is similar to git rebase --exec, but note that stgit rolls back the entire operation on failure rather than leaving you at the failing point. It's giving all-or-nothing, and honestly? Respect πŸ™Œ


πŸ‘‘ STGIT πŸ‘‘

Part of the StGit suite β€” see stg(1) πŸ¦‹


StGit 2.7.0, dated 10/17/2026 β€” that's the version and date bestie, and that's the whole page πŸ’œβœ¨ Slay, go rebase something. πŸŽ€

πŸ“¦ where this page comes from