1

How do you protect your team's git remotes?
We tend to protect the master and stage branch from force pushing and only allow merging pull requests after successfull recent tests and successfull review by someone with proper permissions. Depending on the project the Dev branch is only protected from force pushing though. All other branches are free to handle however wanted.

We recently had someone do a "git push -f --mirror" without understanding the command. Quick reminder what that does: it mirrors all your local branches to the remote so that the remote will be a mirror of your local repo. Branches that exist on remote but not on your machine will be removed from the remote.
A then needed to work from B's feature branch but of course that was gone... So while the idiot didn't fuck up our protected branches he still fucked over other people's workflow with that.

Is there an alternative to outright blocking force pushes which could have prevented that (except force pushing intelligence into his brain)?

Comments
  • 3
    We work in forks, separating the master repo and branches away from the devs, you can only merge to the master repo from a reviewed PR.
    They can do anything they like to their fork, delete it if they want for all I care. It's easier to fix a devs form then it is to fix the main repo.

    This flow has its own issues like visibility and conflict resolution, but you know the master repo is protected from idiots.
  • 2
    Doesn't gitlab have protected branches for exactly that?
  • 0
    @nitwhiz we use GitHub and yes that's what protected branches are for. You could easily wildcard protect any branch, but I was asking If anyone had other ideas 😋
  • 0
    @C0D4 so basically the Open source approach? I feel it would slow down tremendously at first until everyone would get the hang of it but I like the idea
  • 3
    you hire Linus Torvalds and if some idiot tries funny stuff like git push mirorr he will insult the idiot that much that he never dares to do funny stuff again 😆
  • 0
    Add a policy that only allows you to delete your own branches
  • 0
    Do not restrict anyone from doing whatever with their own feature branches. If you do, you loose the backup capabilities of git, as people will only push once they have something to publish.
Add Comment