I have forked a branch from a repository in GitHub and committed something specific to me. Now I found the original repository had a good feature which was at HEAD
In my use case we had a similar need for CI CD. We used git flow with develop and master branches. Developers are free to merge their changes directly to develop or via a pull request from a feature branch. However to master we merge only the stable commits from the develop branch in an automated way via Jenkins.
In this case doing cherry-pick is not a good option. However we create a local-branch from the commit-id then merge that local-branch to master and perform mvn clean verify(we use maven). If success then release production version artifact to nexus using maven release plugin with localCheckout=true option and pushChanges=false. Finally when everything is success then push the changes and tag to origin.
A sample code snippet:
Assuming you are on master if done manually. However on jenkins, when you checkout the repo you will be on the default branch(master if configured).
git pull // Just to pull any changes.
git branch local- // Create a branch from the given commit-id
git merge local- // Merge that local branch to master.
mvn clean verify // Verify if the code is build able
mvn release:clean release:prepare release:perform // Release artifacts
git push origin/master // Push the local changes performed above to origin.
git push origin // Push the tag to origin
This will give you a full control with a fearless merge or conflict hell.
Feel free to advise in case there is any better option.