Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| git_rebase [2019/03/04 21:41] – created rpjday | git_rebase [2019/04/06 21:34] (current) – [Removing a sequence of commits] rpjday | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| < | < | ||
| - | git rebase [-i | --interactive] [< | + | $ git rebase [-i | --interactive] [< |
| - | [< | + | |
| - | git rebase [-i | --interactive] [< | + | [< |
| - | --root [< | + | |
| - | git rebase --continue | --skip | --abort | --quit | --edit-todo | --show-current-patch | + | $ git rebase [-i | --interactive] [< |
| + | | ||
| + | --root [< | ||
| + | - | ||
| + | $ git rebase --continue | --skip | --abort | --quit | | ||
| + | --edit-todo | --show-current-patch | ||
| </ | </ | ||
| - | ===== DESCRIPTION | + | ===== The fundamental rebase operation |
| + | |||
| + | Three components define a rebase: | ||
| + | |||
| + | * the //branch// to be rebased | ||
| + | * the amount of that branch to be rebased | ||
| + | * the target //commit// onto which to rebase | ||
| + | |||
| + | ===== Examples ===== | ||
| + | |||
| + | ==== Simple example ==== | ||
| + | |||
| + | < | ||
| + | A---B---C | ||
| + | / | ||
| + | D---E---F---G | ||
| + | </ | ||
| + | |||
| + | One of: | ||
| + | |||
| + | < | ||
| + | $ git checkout topic | ||
| + | $ git rebase master | ||
| + | </ | ||
| + | |||
| + | or: | ||
| + | |||
| + | < | ||
| + | $ git rebase master topic | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | A' | ||
| + | / | ||
| + | D---E---F---G | ||
| + | </ | ||
| + | |||
| + | ==== Example requiring " | ||
| + | |||
| + | < | ||
| + | o---o---o---o---o | ||
| + | \ | ||
| + | o---o---o---o---o | ||
| + | \ | ||
| + | o---o---o | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ git rebase --onto master next topic | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | o---o---o | ||
| + | / | ||
| + | o---o---o---o---o | ||
| + | \ | ||
| + | o---o---o---o---o | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ==== Removing a sequence of commits ===== | ||
| + | |||
| + | Given: | ||
| + | |||
| + | < | ||
| + | A <--- B <--- C <--- D <--- E <--- F [HEAD] | ||
| + | </ | ||
| + | |||
| + | we could remove C and D with: | ||
| + | |||
| + | < | ||
| + | $ git rebase --onto B D [HEAD] | ||
| + | </ | ||
| + | |||
| + | to get: | ||
| < | < | ||
| - | If <branch> is specified, git rebase will perform an automatic | + | A <--- B <--- E' <--- F' |
| - | git checkout | + | |
| - | remains on the current branch. | + | |
| </ | </ | ||