I created a new branch named newbranch from the master branch in git. Now I have done some work and want to merge newbranch to master; however, I have made some extra changes to newbranch and I want to merge newbranch up to the fourth-from-the-last commit to master.
I used cherry-pick but it shows the message to use the right options:
git checkout master
git cherry-pick ^^^^HEAD newbranch
Can I use git merge to do it instead?
git merge newbranch <commitid>
Sure, being in
masterbranch all you need to do is:where
commit-idis hash of the last commit fromnewbranchthat you want to get in yourmasterbranch.You can find out more about any git command by doing
git help <command>. It that case it’sgit help merge. And docs are saying that the last argument formergecommand is<commit>..., so you can pass reference to any commit or even multiple commits. Though, I never did the latter myself.