From 251da2fafa7b07dd1f0e9fbf59660217b483fd24 Mon Sep 17 00:00:00 2001 From: Chalarangelo Date: Thu, 8 Apr 2021 20:10:35 +0300 Subject: [PATCH] Add interactive rebase --- snippets/interactive-rebase.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 snippets/interactive-rebase.md diff --git a/snippets/interactive-rebase.md b/snippets/interactive-rebase.md new file mode 100644 index 000000000..08d2b7716 --- /dev/null +++ b/snippets/interactive-rebase.md @@ -0,0 +1,24 @@ +--- +title: Perform an interactive rebase +tags: branch,advanced +--- + +Performs an interactive rebase. + +- Use `git rebase -i ` to perform an interactive rebase. +- You can edit the rebase file to change the order of the commits and the action to perform for each one (pick, squash, drop, reword etc.). +- You can optionally use the `--autosquash` option to automatically squash fixup commits. +- If you have merge conflicts or stop to make changes, you can continue the rebase when ready using `git rebase --continue` or abort it using `git rebase --abort`. + +```sh +git rebase -i [--autosquash] +``` + +```sh +git rebase -i 3050fc0de +# Performs an interactive rebase starting from `3050fc0de` + +git rebase -i --autosquash HEAD~5 +# Performs an interactive rebase of the last 5 commits, +# automatically squashing fixup commits +```