tldr/pages/common/git-rebase.md

29 lines
894 B
Markdown
Raw Normal View History

# git rebase
> Reapply commits from one branch on top of another branch.
> Commonly used to "move" an entire branch to another base, creating copies of the commits in the new location.
- Rebase the current branch on top of the master branch:
`git rebase master`
2015-12-30 17:36:58 +00:00
- Start an interactive rebase, which allows the commits to be reordered, omitted, combined or modified:
2015-12-30 17:36:58 +00:00
`git rebase -i {{target_base_branch}}`
2015-12-30 17:36:58 +00:00
- Continue a rebase that was interrupted by a merge failure, after editing conflicting files:
2015-12-30 17:36:58 +00:00
`git rebase --continue`
- Abort a rebase in progress (e.g. if it is interrupted by a merge conflict):
2015-12-30 17:36:58 +00:00
`git rebase --abort`
2016-09-21 07:58:28 +01:00
- Move part of the current branch onto a new base, providing the old base to start from:
2016-09-21 07:58:28 +01:00
`git rebase --onto {{new_base}} {{old_base}}`
- Reapply the last 5 commits in-place, stopping to adjust them (reword, combine, reorder or remove):
`git rebase -i HEAD~5`