1

When i am working locally i sometimes accidentally delete my develop/master branches or sometimes commit to them directly instead of the feature branches.

Is there any extension/add-on that would protect certain git branches?

  • 2
    I don't think so, specially because given that they are _local_, you can always get stuff back to how it was if you notice that something did not go according to plan without affecting other people (unless you push the wrong stuff, of course). – eftshift0 Nov 09 '22 at 10:40
  • 3
    Just in case, and if you feel hard-pressed for it, you might want to play a little bit with git hooks so that you can run some checks for some of the operations. Check `git help hooks`. – eftshift0 Nov 09 '22 at 10:41
  • 1
    Specifically, the `pre-commit` hook can reject a commit if it can decide the branch is wrong. Not sure about accidentally deleting a branch (how do you do that?), but you can always recover them – Useless Nov 09 '22 at 10:43
  • 1
    Something like this: https://stackoverflow.com/q/56987596/7976758 or https://stackoverflow.com/q/29229247/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+pre-commit+hook+prevent+committing+master – phd Nov 09 '22 at 15:33

0 Answers0