In many setups, the Master branch is protected from direct pushing. When developing locally, people branch a feature branch of a local copy of the master branch and then one can rebase the feature branch onto the master branch. I wonder how then these changes are published because this would mean that one has to push the changes onto the remote Master branch.
What is the recommended best practice for publishing changes which have been rebased onto the local master branch when the remote master branch is protected from direct pushing?
CodePudding user response:
People would rebase on top of master or main, meaning pull in master/main changes and place the changes on their feature branch on-top.
git rebase -i origin/main
Once this is done they would force push to their feature branch to overwrite the history removing tidying up obsolete commits with an f
or fixup
. That cleaned history on the feature branch should then be merged back into main/master via pull-request.
git push --force
An admin can modify commits on master and push directly if the repository settings allow it but it should be avoided due to the risk of damaging history on the trunk.