Comment on Discussion of the Benefits and Drawbacks of the Git Pre-Commit HookparentComments−AndrewDucker10moYes, but I'd like to avoid the "create a new branch, switch back to main, reset main back to origin, come back to the new branch" dance. And a git hook does that, but it's not trivial to set up (particularly when there are lots of repos).−indentit10moMaybe create a shell alias which would act as a wrapper around git to do just that, when you try to commit on the wrong branch
Comments
Yes, but I'd like to avoid the "create a new branch, switch back to main, reset main back to origin, come back to the new branch" dance. And a git hook does that, but it's not trivial to set up (particularly when there are lots of repos).
Maybe create a shell alias which would act as a wrapper around git to do just that, when you try to commit on the wrong branch