Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge commit without parent

Tags:

git

git-merge

Let's say I have the following commits in my master:

master  : ---A----B----C----D---E

Now I need to create new branch from commit A and include only changes in commit C

master  : ---A----B----C----D---E
              \        
branch2 :      \-------C

So I need to put in my branch2 commit C without B

How can I do that ?

like image 223
Pydev UA Avatar asked Mar 02 '26 22:03

Pydev UA


1 Answers

Use cherry-pick

git checkout -b branch2 <shaSUM of A>
git cherry-pick <shaSUM of C>
like image 52
TheOneTeam Avatar answered Mar 04 '26 12:03

TheOneTeam



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!