2

There are some people working on repository and it will be bad if someone make push -f with only first commit.

How to prevent this action at Bitbucket?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Vassily
  • 5,263
  • 4
  • 33
  • 63
  • Possible duplicate of [Is there a way to configure git repository to reject 'git push --force'?](http://stackoverflow.com/questions/1754491/is-there-a-way-to-configure-git-repository-to-reject-git-push-force) – TheGeorgeous Dec 28 '15 at 04:51
  • Bitbucket has a few options to protect branches: https://confluence.atlassian.com/bitbucket/branch-management-385912271.html – Thilo Dec 28 '15 at 04:54

2 Answers2

6

The solution is to give write access to only the developers that you trust. Normally you have the team lead managing the main repository, and everyone else has forked a copy of this repository.

Using this method, everyone has their own copy that they can destroy if they wish and it won't affect your main repository. Once the contributors are ready to merge their code, they need to create a pull request. It is at this point the team lead is able to review the changes and accept/reject.

Not only does this method protect against push -f commits, it prevents many other unwanted changes as well.

Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
0

The git option you are looking for is receive.denyNonFastForwards. Bitbucket should let you configure that: https://bitbucket.org/site/master/issues/4002/allow-users-to-set-the-flag

andreas-hofmann
  • 2,378
  • 11
  • 15