Given the comment posted by OP on Ryen Nelsen's answer:
... master/develop separation is not really an issue - usually I follow gitflow paradigm. What I'm interested in - how to send pull-request for only feature-X, given that my develop is way ahead of the original repository? I use cherry-picking, but is it the best way?
I will ask - what do you mean that your develop
branch is way ahead of the original repository (what I'll call the master
branch from now on)? What are all the other things in your develop
branch?
It sounds like you are completing significant development in develop
that is not going into master
in the short-term. In this situation, create a separate feature branch for each Pull Request/issue/enhancement that you are working on that will be submitted to master
.
If you are careful, you can minimize the differences between your various feature branches, including the interdependencies discussed in the quote. For example, say you are maintaining develop
and trying to submit pull requests to master
for fea1
and fea2
.
- Setup the 2 feature branches off of master and Cherry-pick or Rebase out of develop to
fea1
and fea2
until they have the base you need from existing develop
changes to make your fixes.
- If there are interdependencies, that just means you will cherry-pick some of the same commits to each feature branch, or will end up developing new code that will be merged or rebased between the two feature branches.
- Develop the new fixes for
fea1
and fea2
, and merge (or rebase/squash) to develop
as you find appropriate. Merging in this context, where you are the only one developing in this repo is simple - you'll only be working on one of develop
, fea1
, or fea2
at a time, so merging is truly going to be handling conflicts that you have to solve anyway...
Once prepared for the pull requests, you can leave fea1
and fea2
sitting in their own separate branches, and continue working on develop
separately. Meanwhile, as the Pull Requests get feedback you can always checkout fea1
or fea2
and update them, perhaps requiring a merge from fea1
to fea2
or vice versa, and likely also needing to merge the new commit(s) back down to develop so it stays up-to-date.
Once the PRs are accepted, you can clean-up anything you need to on the corresponding private feature branch in your repo, and make sure any final merges to the other branch and develop
are complete.
You could then delete the feature branch, but personally, I'd tag the last commit so I could come back to it in the future if needed, and then delete the branch reference. That way you can come back to a commit that is likely a lot closer to master
than develop
is, though depending how much time has passed, maybe not - at least you'll have a choice. This could happen, for example, if a defect in your PR gets into master,
and a new issue is opened that you can squash quickly, but would take someone else a lot longer.