I use git-flow and from the Github protection rules I have branches master
and develop
protected, both with the option Require linear history
.
All works fine, but now I would like to instead of just merging from develop
to master
, start using "pull requests" (develop -- PR --> master
) I would like to know if it is possible to keep the branches even/sync while keeping the history linear, without out need to do a force push on the develop
branch.
Currently, If I create a pull request PR
from develop
to master
and because the Require linear history
option is checked, I can't merge but only squash and merge
or rebase and merge
because of this if I modify the develop
branch and make another commit it becomes N times ahead but it can never be "even".
The only way I have found to make develop
even with master
is with
git pull origin master --rebase
But this then later implies force push:
git push -f
When not using PR
I simply merge develop into master (FastForward) and keeps history linear, I could merge the pull requests and prevent the force push by disabling the Require linear history
, but history will not be linear. (I think the PR's are not being merged using FastForward)
The reason for me to use git-flow is that the develop
branch is used by the CI/CD and deploys to staging and master
to production, I am aware that partially this could be solved by using tags
so that everything merged into master
without tag could be deployed to "staging" and only tags to "production" but for now having this constraint of branches master
and develop
what could be the best way to keep branches as sync as possible?