Changing the Origin of your Branch

Today I learned that you can change the origin of your branch in Git.

Changing the Origin of your Branch
Photo by Anne Nygård / Unsplash

Today I learned that you can change the origin of your branch in Git.

Change branch base
I’ve a tree like this: (commit 1) - master \-- (commit 2) - (commit 3) - demo \-- (commit 4) - (commit 5) - PRO and I have to move ...

Use Case

the Developer was meant to create a bug branch off of a specific patch branch, but did it off of the next minor release.

The concern here is that the Pull Request for the bug branch will contain everything from the Release at the point of branch off which may contain breaking changes.

The Resolution is to rebase the bug branch with the Patch branch changing the origin and thus removing the commits from the Release branch.

git rebase --onto newBase oldBase feature/branch