I want to merge not the HEAD of my develop into the master branch but say five commits before theHEAD. How can I achieve this?
git merge actually works directly with commit IDs, so:
$ git merge a12399c
will attempt to merge that commit (and its history) with your current branch.
You can spell a commit ID with a branch name:
$ git merge develop
and the branch name resolves to the tip commit of the branch. This is what you are used to doing (and it is "better", in some sense, since the default merge commit message becomes "merge branch develop" rather than "merge commit a12399c"). But you can use a raw ID, or any other spelling for an ID, such as:
$ git merge develop~5
which uses gitrevisions syntax to name the commit to merge.
(If you're not doing the merge yourself, but rather sending pull requests, you do need a name, because you don't do the merge. Instead, you send a request to someone else, asking them to do the merge for you—and to do that, you tell them "use this name I have set, that points to the commit ID I would like you to merge." The main complication here is that the name must be visible to the other person. The easiest way to deal with all of this is to set up a branch name, since branch names are visible to other people.)
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