This is my scenario:
master
branchmaster
branch, the branch feature1
was createdfeature1
and other commits were added to master
feature1
and apply them to master
.I want to go from this:
(branch) feature1: f1 > f2 > f3 > f4
/
(branch) master: A > B > C > D
To this:
(branch) feature1: f1 > f2 > f3 > f4
/
(branch) master: A > B > C > D > f3 > f4
You can observe last hashes of your commits by running
git log -N
where N is number of commit hashes you want to see.
and then you can do
git cherry-pick {firstHash}^..{lastHash}
where {firstHash}
and {secondHash}
are starting point and ending point of your cherry-picking , its like closed interval [firstHash,lastHash] , so all commits in between will be taken as well.
Note: firstHash
has to come before lastHash
for obvious reasons.
if you don't want them to be commited and you only want the content of them you can do
git cherry-pick {firstHash}^..{lastHash} --no-commit
In your case if we consider (f1,f2..) are commit hashes, this should do the drill:
git checkout master
git cherry-pick f3^..f4
If there are any merge conflicts you gonna have to resolve them and call git cherry-pick --continue
(sometimes git bash is stubborn about it and it doesn't show you that) to be able to continue onto the next commit.
In any case you should check the documentation of cherry pick as @Erhan mentioned - https://git-scm.com/docs/git-cherry-pick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With