0

I want to know if there's an option to disable committing to a local branch. I forget sometimes to open a new branch when developing. Thanks in advance.

Amit Toren
  • 353
  • 5
  • 13

1 Answers1

0

There are hooks you can install which get executed before a commit. See here.

Also if you have already written code and realize you're on the wrong branch you could git stash the changes.

Sogomn
  • 304
  • 3
  • 16
  • I tried doing git stash but it weirdly put some unknown files in my commit. Maybe I did something wrong. Are the hooks going to work on a commit to a local branch? – Amit Toren Nov 08 '17 at 12:29
  • Well what else do you want to commit to other than a local branch? – Sogomn Nov 08 '17 at 12:45
  • I want a branch that the only action you can do on it is pull. It's the dev branch that everytime a branch gets approved it upload it to the dev branch. So the only thinf I want permitted on the dev branch is pull. – Amit Toren Nov 08 '17 at 13:16
  • That should be possible with a pre-commit hook. https://git-scm.com/book/gr/v2/Customizing-Git-Git-Hooks – Sogomn Nov 08 '17 at 13:18
  • Also you could manually alias all git commands to execute a script instead. – Sogomn Nov 08 '17 at 13:20
  • Awesome. I'll try it out. Thanks. – Amit Toren Nov 08 '17 at 14:34