Is there a way to configure git repository to reject 'git push --force'?
git
Solution
Setting the configuration variables:
receive.denyNonFastForwards
receive.denyDeletes
will prevent any 'forced' pushes from working across all branches.
If you want finer pre-branch control then you will have to use a 'hook' on the remote repository, probably the 'update' hook.
There is a sample update hook called 'update-paranoid' that probably does what you need (and more) in the git distribution in the 'contrib' folder.
gitweb link
Problem
I was wondering is there a way to prevent '`git push --force`' on a repository (only on master branch)? Assume I have remote git repository and do: - '`git push`' to 'master'. It works. - '`git push --force`' to 'branch-1'. It works. - '`git push --force`' to 'master'. It is rejected. Is it even possible?