Created
December 9, 2016 10:37
-
-
Save iolloyd/4018744c054b223c035ed8233f1ea6ce to your computer and use it in GitHub Desktop.
Branching from the wrong branch in git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# branch/current <- Branch with commits | |
# branch/main <- Branch that should have been branched from | |
# branch/other <- Branch that was actually branched from | |
git checkout branch/main | |
git checkout -b branch/correct | |
git rebase --onto branch/correct branch/other branch/current |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First, checkout the branch that you wanted to branch from originally.
Make a new branch, here we've called it branch/correct.
Rebase the changes made that are the difference between the branch you branched from and the branch you made with your latest commits.
Done.