- Command used to reapply commits on top of other branch - All commits are **rewritten** meaning that you will have different commit IDs in history - Rebase is performed from source (feature branch) to target (for example master branch) - Being checked-out to feature branch: `git rebase` . Use `-i` for interactive mode. - **Golden rule - never use `rebase` on public branches (for example 'main' that is used by others)** To perform rebase interactively, use `git rebase -i main` command. This command allows you to select commits from the list that will be rebased into target (main in this case) branch and decide what you want to do with them. The possible options are: - `pick` - include particular commit into rebasing process - `reword` - similar to `pick`, but it allows you modify the commit message (rebase process would stop to let you modify the message) - `squash` - combine two or more commits into a single one. Commit marked with `squash` keyword is squashed into the commit that is above it. It also allows you to write your own message. - `fixup` - similar to `squash`, but the commit message from the commit being fixed up is ignored. It simply means that this performs `squash` and uses the commit message from the commit above. - `edit` - rebasing process will stop at the commit market with this keyword and you'll be allowed to amend the commit. You can also make more commits before you continue the rebase. - `exec` - allows you to run shell commands against a commit (stops rebasing at this point) ### See also 1. [[Git]] ### Reference 1. [Git-rebase docs](https://git-scm.com/docs/git-rebase)