在将git更改为遥远的分支之前,是否有办法在VS代码中警告我?
我经常犯同样的错误,我对代码进行了一些更正(或修改),忘了为其创建一个新的分支,而直接将其推到Gitlab Repo的 develop 分支上。
在将更改推向遥远的存储库之前,有没有办法在VS代码中加热?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以通过保护分支来保护该分支,并且只允许Gitlab中的拉请请求:
参见 https://docs.gitlab.com/ee/user/project/protection_branches.html#require-everyone-veryone-to-submit-merge-requests-for-a-aprotected-branch-
noreferrer “ 拒绝了,就像前挂钩一样。
You could also protect the branch by making it protected and only allow pull requests in GitLab:
See https://docs.gitlab.com/ee/user/project/protected_branches.html#require-everyone-to-submit-merge-requests-for-a-protected-branch
The push will be rejected, just like the pre-push hook.
您必须实现
pre-per-per-per-push
钩子。在挂钩脚本内部检查使用的分支,并询问用户是否要推开,如果不返回1,否则返回0。
您可以使用任何要编写脚本的语言。
查看
.git/hooks/pre-push.sample
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
自2022年5月以来(版本1.68),现在可以使用
git.branchprotection
和git.branchprotectionprompt
直接保护,从vs Code中保护一些Git分支。那正是我想要的。
请参阅此链接(在写作时,我找不到任何文档) 。
Since May 2022 (version 1.68), it is now possible to use
git.branchProtection
andgit.branchProtectionPrompt
to protect, directly from VS Code, some Git branches.That's exactly what I was looking for.
See this link (at the time of writing, I can't find any documentation).