LinuxCommandLibrary

git-rebase

Reapply commits on new base

TLDR

Rebase onto branch

$ git rebase [branch]
copy
Interactive rebase
$ git rebase -i [commit]
copy
Rebase last N commits
$ git rebase -i HEAD~[n]
copy
Continue after conflict
$ git rebase --continue
copy
Abort rebase
$ git rebase --abort
copy
Skip current commit
$ git rebase --skip
copy
Rebase onto specific base
$ git rebase --onto [newbase] [oldbase] [branch]
copy

SYNOPSIS

git rebase [options] [upstream] [branch]

DESCRIPTION

git rebase reapplies commits on top of another base tip, producing a linear project history. It finds the common ancestor of the current branch and the upstream, then replays each commit from the current branch onto the upstream tip.
Interactive mode (`-i`) allows reordering, squashing, editing, or dropping commits during the replay, making it a powerful tool for cleaning up commit history. The `--onto` option enables advanced workflows like moving a branch to an entirely new base. Autosquash automatically applies fixup! and squash! commits, supporting the iterative fixup workflow.

PARAMETERS

-i, --interactive

Interactive mode.
--onto newbase
Rebase onto different base.
--continue
Continue after resolving.
--abort
Cancel rebase.
--skip
Skip current patch.
--autosquash
Auto-apply fixup/squash.
--autostash
Auto-stash changes.
-x cmd
Run command after each commit.
-p, --preserve-merges
Preserve merge commits.

CAVEATS

Rebasing rewrites history. Don't rebase commits that have been pushed to shared branches.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community