I'll give some context before jumping to the actual questions: I'm the only developer working on a project, where I have main
, develop
and staging
branches, besides all feature/* and hotfix/* that I could potentially have during development.
The integrations between branches were made via pull requests using GitHub, some of them were made with merge commits, others with squash commits, so the result is that the branches got very messy. For example, I just merged staging to main
, then updated (merged) main
to both develop
and staging
. As I'm the only developer, I know that the content at this point for all the three branches is the same, but commit-wise is not: both develop
and staging
are 382 commits ahead of main
.
When I create a pull request to staging
over a branch checked out from develop
, the pull request shows only the commits about the feature itself, which is good. Buy when I create the pull request to main
over staging
, a lot of commits that aren't related of this request are showing (because they are commits from develop
and staging
, but not in main
) and making the code review messy, also the changelog management.
For me (and correct me if I'm wrong, please) the perfect scenario would be having main
, development and staging
with exactly the same content and commit count (i.e., development and staging
show 0|0 ahead/behind main
). I could delete and recreate both develop
and staging
branches from main
, but (and here comes the first question) is there a way to reset develop
and staging
branches without recreating them?
The second question is kinda obvious: which way do you think is the cleanest to handle the following pull requests to keep a clean situation in the future?. I think that any merge-based solution will include at least one commit, so maybe the answer goes through rebase.