How to prevent push -f at git repository on bitbucket?

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?

  • Git: Pulling from remote
  • “git pull --rebase” in Eclipse
  • The way to “reinit” repository
  • Git: Unable to understand why branch (topic) commits/merges are happening on the master branch
  • Ignoring a directory…but not a subdirectory or two
  • Git: can I suppress listing of 'modified content'/dirty submodule entries in status, diff, etc?
  • Cannot ignore .idea/workspace.xml - keeps popping up
  • Edit an AndroidManifest when compiling to remove API-key
  • Is it possible to make git svn dcommit result in a single svn commit?
  • Github Windows 'Failed to sync this branch'
  • Is this a good strategy to undo git stuff?
  • What's the Git approach to publish a patch queue?
  • 2 Solutions collect form web for “How to prevent push -f at git repository on bitbucket?”

    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.

    The git option you are looking for is receive.denyNonFastForwards. Bitbucket should let you configure that:

    Git Baby is a git and github fan, let's start git clone.