Is it necessary to prohibit git push origin master -f in the repository?

My team faced a tough debate on whether to prohibit the making push's master key with force at the level of the repository.

Our production process follows. When another developer takes a task, it creates a separate branch, which is repulsed from the actual master. As soon as the task is finished, we need to create a merge request, which needs to see someone from the team. If everything is in order, the branch merges with the master and then deleted. We use hitlab, which allows you to merge a branch with master click of a mouse.

Once master got a branch there to be more than it should. So it was that hung the merge request has been comments, but the person who looked through the code clicked in the wrong place, where it was necessary and leaked the unfinished branch with the master. Was immediately made of revert, which is essentially a commit, destroying previous merge. This is the revert provoked a few problems. In the end, the following has been done -- this is the random merge was "cut", followed by a terrible command git push origin master --force-with-lease.

In my opinion this decision was justified because:

  1. In the history of versions will not be garbage. Really-just entered the merge inadvertently, the top fell on him reverse-commit. But as soon as zaimplementowana things that appeared after the review, will be another merge with the only difference that he will be in a few more commits. In the end we have a lot of unnecessary code history.
  2. In our particular case, if you don't cut out the failed merge, in the end, after the implementation of the observations would have to do a rebase on current master (which has been reverse-commit) and it would create a lot of conflicts that would have to untie.

In my opinion this decision was more than justified, however, began holivar.

  1. Who believes-whether to disable the ability push'and force?
  2. What do You do if the wizard accidentally hit something that should not be there?
July 12th 19 at 17:27
3 answers
July 12th 19 at 17:29
1. Rewriting history is needed, but it needs to be used carefully. Push with force into the master exception to the rule, and in your situation it is completely justified.

2. In 99% of cases makes a revert. In other cases - push --force, but this is extremely rare.

In General I'm a fan of rebase-s, what would the story of Gita was linear. If fiebranz not fast forward it rebassa on the master and re-writable history of this thread. Well, then fast-forward merge (and even better - squisite commits before that). But there can be dissent, because I use those options which are accepted in the team.
July 12th 19 at 17:31
In my opinion the development should be done in the develop branch (oddly enough). Thus the only way of getting code into master drain current develop to master.
Thus the master will always be ready, working, clean release, while the current development is to develop.

Regarding the issue
1. to allow direct push to master on good it is necessary, but when there is force majeure and will need something to roll one hell climb to enable push)
2. revert doing, what else is there to do)
Often the develop branch is not needed, only a stable master. By "stable" I mean "everything works", that is, the tests are green (otherwise the master is not fall), and you are sure you did everything in accordance with the requirements. If you are not sure - then this has no place in the wizard.

It is true there is a small assumption - developers adequate, all covered by tests, and the developers really know what to do and most importantly check what I did. I've seen a lot of developers are rolling out all testing deliberate knowing that did not complete or just not checking.

master must be always ready for the deployment. If it needs to develop a branch - okay, but it may not be necessary. - broderick_Gleas commented on July 12th 19 at 17:34
July 12th 19 at 17:33
Commit history and the history that would display all changes in chronological order.

do I need to disable the ability push'and force?

Git push should be banned, at its core is Domoklov sword, just above the heads of the whole team.
I met several times after a forced push is not successful rebase. Once a colleague had to restore a 2-week history, not the most pleasant experience.

What do You do if the wizard accidentally hit something that should not be there?

revert comment in the bug tracker about the cause of reverta.

On past project releases was 1 times in the morning and an optional day. The release was carried out in semi automatic mode, branches dragged out of the bugtracker and then was namecialis on the master. In the event of a conflict - auto-revert. In the event of a breakdown Assembly manual search of the culprit and hand revert.
A forced push is not needed. Rebels not stuck.
Yes, fucapi been, for this was optional releases a day, what would the author of seeing your school on the prod could the same day it Asano to fix it.

Find more questions by tags GitLabGitOrganization of the work