I would like to protect my git repository so only non master branches can be overwritten. Is there a way to protect only selected branches?
You can use GitEnterprise to setup per-branch permissions (admin) to block non-fastforward pushes using fine-grained access permission.
And git config --system receive.denyNonFastForwards true
will simply do the job if you need to block history changing for all branches.