I often do the same mistake, I do some corrections (or modifications) on my code, forgot to create a new branch for it and push it directly on the develop branch of my Gitlab repo.
Is there a way, in VS Code, to be warmed before pushing changes to a selected branch of the distant repo ?
CodePudding user response:
You could also protect the branch by making it protected and only allow pull requests in GitLab:
Require everyone to submit merge requests for a protected branch
You can force everyone to submit a merge request, rather than allowing them to check in directly to a protected branch. This setting is compatible with workflows like the GitLab workflow.
The push will be rejected, just like the pre-push hook.
CodePudding user response:
You have to implement a pre-push
hook.
Inside the hook script examine the branch used and ask the user if he wants to push and if not return a 1 otherwise return a 0.
You can use any language you want to write the script.
Look at the .git/hooks/pre-push.sample