How to ensure that any pull request coming to RELEASE branch has code cherry picked from develop branch only and not from any feature branches? To elaborate, whenever a fix is supposed to go to RELEASE branch, developer creates a release-fix branch off of RELEASE branch, then he/she has to cherry pick code from develop in to the release-fix branch and then raise a pull request from the release-fix to RELEASE branch. So basically the fix has to be pushed to develop first which is then cherry picked in to the release-fix branch. How to ensure that the code that is in release-fix branch came from develop and not from any other feature branches? Rather than verbal advice, is there a way to enforce this at git hub or in Jenkins?
If you're using the `git cherry-pick` command, there isn't a good way to do what you're asking. This is because `git cherry-pick` creates new commit objects that contain the same changes as the original commits, but otherwise they're unrelated to the original.
It sounds like what you're doing is something like this:
This kind of setup would force the workflow that it sounds to me like you're describing. However, if you changed the setup a bit to something like this:
Then you wouldn't need to use the cherry-pick command and the requirement that things go to develop first wouldn't be necessary either. If you really want to keep a hold of the develop branch (maybe there's some important QA step that happens there), then you could use a setup like this:
The two options I mention above are more common solutions to standard development workflows. `git cherry-pick` is almost never used in the standard flow of changes through a development process. It's used for "jumping the line", like when an important change needs to be taken from development straight to release without the standard certification steps.
To answer your original question though, you can use branch protections to prevent anyone but approved people from merging into specific branches. But it restricts merges based on the destination of the merge, not the source.
I hope that helps!