Git: Disable Force Push
We have all heard of horror stories as a result of misusing git push --force
.
If you have the appropriate permissions on your "central" git repository, you can disable force push by git config --system receive.denyNonFastForwards true
.
For Github Enterprise, you can follow instructions on this page to disable force push.
For other Github repositories (the ones that most of us use daily), there are no ways to disable force push. Some workarounds include:
- Limiting the group of people will push privileges. Other contributions will have to come in as Pull Requests.
- Set up an intermediate repo on your side with a
pre-receive
hook to prevent force push.
Written by Ivan Sim
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#