From d540ba1e4820f20be95939f3ae4522f925f6fce0 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Mon, 5 Apr 2021 11:19:54 +0300 Subject: [PATCH] Add rebase onto --- snippets/rebase-onto-branch.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 snippets/rebase-onto-branch.md diff --git a/snippets/rebase-onto-branch.md b/snippets/rebase-onto-branch.md new file mode 100644 index 000000000..232413008 --- /dev/null +++ b/snippets/rebase-onto-branch.md @@ -0,0 +1,25 @@ +--- +title: Rebase onto another branch +tags: branch,intermediate +--- + +Rebases the current branch onto another branch. + +- Use `git checkout ` to switch to the `` to be rebased. +- Use `git rebase ` to rebase the current branch onto ``. + +```sh +git checkout +git rebase +``` + +```sh +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` +```