Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on Turn all changes after latest origin/main into a branch
Parent
Turn all changes after latest origin/main into a branch
+2
−0
I have a git history that basically looks like this:
* commit: XXX (HEAD -> main)
|
|
* commit: YYY
|
|
* commit: ZZZ (origin/main)
|
|
...
Now I would like to turn everything after the last origin/main into a named branch (that is, the changed repository would look as if I branched at commit: ZZZ).
Is this possible, and if so, what is the best way to do it?
Post
+6
−0
First you want to make your new branch at HEAD
(current main
). Then you want to point main
back to origin/main
.
# Create new branch
git branch new_branch_name
# Point main back at origin
git reset --hard origin/main
0 comment threads