In our current workflow, we have 2 main git branches:
master
- stable release branch
testing
- were everyone tests their code
Now every developer creates new branches for each feature they develop. When they are done, they merge it to testing
, and when our QA says it's good to go, they merge their branch into master
which gets deployed into production.
As time passes, our testing
branch get polluted with commits that never make it to production. Abandoned features, stuff that got rewritten instead of fixed and other things.
To keep master
and testing
in a somewhat consistent state, we'd like to "reset" testing
from time to time. Right now, we do so by entirely removing testing
and re-branching it from master
.
The big problem here is that we need to make sure that every single developer also remove his local testing
branch and checks out a fresh copy of it.
If one developer forgets to do that and pushes to testing again, all the dirty commits that we are trying to get rid of are back.
Is there any way to reset a branch on the server in a way that it distributes to all users?
An acceptable solution would also be putting the testing
branch in a state where nobody can push to it anymore without doing a reset locally. But I can't think of a way how to do it.
Creating a diff between master
and testing
and reverting commits is not an option as this prevents each of these commits to ever go into testing again.
Ideally, I'd have a script that performs this reset periodically and no interaction (other than git pull
) is needed on each users local environment.