Skip to content

Home

Rebase onto another Git branch

If you've ever worked on a large project, you might have come across the need to get your branch up-to-date with another branch. Git provides a way to do this using the git rebase command.

In order to perform a rebase, you'll first have to use git checkout to switch to the branch you want to rebase. Then, you can use git rebase to rebase the current branch onto the target branch.

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.

# Syntax:
#  git checkout <branch>
#  git rebase <base-branch>

git checkout patch-1
git rebase master
# `patch-1` is rebased onto `master`

git checkout patch-2
git fetch origin
# Fetch latest remote branches
git rebase origin/master
# `patch-2` is rebased onto the latest remote `master`

More like this

Start typing a keyphrase to see matching snippets.