Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT how to split up commits from branch into different branches?

Tags:

git

I have a single branch with commits for feature A, B, C, D. I have about 40 commits, and each of the commits are in mixed order. I have made a pull request, but I need to split up this branch into branch A, branch B, etc. with the commits associated with each feature. So feature A commits in branch A.

Unfortunately, i'm new to git and it still confuses me. How do you pull out the commits from a single branch and put them inside their own branch?

like image 360
J. Reku Avatar asked Apr 18 '26 22:04

J. Reku


1 Answers

You can use git cherry-pick Create new branch for feature A, checkout on it and use: git cherry-pick a_commit_hash. Repeat it for all your commits

like image 143
Ivan Sheihets Avatar answered Apr 23 '26 21:04

Ivan Sheihets



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!