'Is there a way, in VS Code, to warn me before pushing git changes to a distant branch?
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 ?
Solution 1:[1]
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.
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Julian |
| Solution 2 |
