在将git更改为遥远的分支之前,是否有办法在VS代码中警告我?

发布于 2025-01-28 15:35:37 字数 125 浏览 0 评论 0原文

我经常犯同样的错误,我对代码进行了一些更正(或修改),忘了为其创建一个新的分支,而直接将其推到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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撩动你心 2025-02-04 15:35:37

您还可以通过保护分支来保护该分支,并且只允许Gitlab中的拉请请求:

要求每个人都提交合并的请求,以保护受保护分支机构

您可以强迫所有人提交合并请求,而不是允许
他们直接检查到受保护的分支。此设置是
与GitLab Workflow之类的工作流程兼容。

参见 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:

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.

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.

城歌 2025-02-04 15:35:37

您必须实现 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

孤单情人 2025-02-04 15:35:37

自2022年5月以来(版本1.68),现在可以使用git.branchprotectiongit.branchprotectionprompt直接保护,从vs Code中保护一些Git分支。

那正是我想要的。

请参阅此链接(在写作时,我找不到任何文档) 。

Since May 2022 (version 1.68), it is now possible to use git.branchProtection and git.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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文