简体   繁体   English

如何使用 git 将 URL 获取到我当前分支的合并请求或拉取请求?

[英]How can I get the URL to a merge request or a pull request of my current branch using git?

I would like to obtain the link to the associated PR/MR of the current branch using Git CLI .我想使用Git CLI获取当前分支的关联 PR/MR 的链接。

Git is unaware of pull (GitHub) or merge (GitLab) requests. Git不知道拉(GitHub)或合并(GitLab)请求。 This means that the Git CLI is unable to do what you want.这意味着Git CLI 无法执行您想要的操作。

Git is, however, a set of tools , not a specific solution.然而,Git 是一套工具,而不是特定的解决方案。 You can simply add your own tools .您可以简单地添加您自己的工具 The Unix-style of working is to treat everything as a tool, to whatever extent possible, so if you're using bash or zsh, you can add non-Git tools as well. Unix 风格的工作方式是尽可能将一切都视为工具,因此如果您使用的是 bash 或 zsh,您也可以添加非 Git 工具。

GitHub, for instance, provide a CLI tool of their own called gh .例如,GitHub 提供了自己的 CLI 工具,称为gh There is a StackOverflow tag for gh-related questions: .与 gh 相关的问题有一个 StackOverflow 标签: There are also GitLab tools, eg, this one and this one , although there don't seem to be StackOverflow tags for these.还有 GitLab 工具,例如this onethis one ,尽管这些似乎没有 StackOverflow 标签。

You'll find one big stumbling block here, and that is the fact that branches, in Git—regardless of which of several common meanings you intend by the word branch —are slippery and have little real substance.你会在这里找到一个很大的绊脚石,那就是分支,在 Git 中——不管你对分支这个词的几种常见含义中的哪一种——都是很滑的,几乎没有真正的实质。 There may be a branch named feature/tall in repository X on GitHub, which you use in your own clone under the entirely different name feature/short . GitHub 上的存储库 X 中可能有一个名为feature/tall的分支,您在自己的克隆中使用完全不同的名称feature/short Is this branch "tall" or "short"?这个分支是“高”还是“短”? The answer is either "yes" or "both".答案是“是”或“两者”。

The simple solution to this stumbling block is "don't do that": if you keep your names such that they match up with some other repository's names , you won't ever hit this problem.这个绊脚石的简单解决方案是“不要那样做”:如果你保持你的名字与其他一些存储库的名字相匹配,你就永远不会遇到这个问题。 The fault with this simple solution occurs when there are multiple "other repositories" in question and they:当有多个“其他存储库”存在问题并且它们:

  • use different names, and/or使用不同的名称,和/或
  • use the same names, but for different commits使用相同的名称,但用于不同的提交

which results in you being unable to use a single name to match.这导致您无法使用单个名称进行匹配。 But this is rare, so you may be able to ignore it.但这很少见,因此您可以忽略它。

You mean https link?你的意思是https链接?

I don't know the way to get the link you want,我不知道如何获得你想要的链接,

but you can get that kind of link by webhook of GitLab after the PR/MR event.但是您可以在PR/MR事件之后通过 GitLab 的 webhook 获得这种链接。

webhook: https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#webhooks网络挂钩: https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#webhooks

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在拉/合并请求之前更新(拉)分支? - How to update(pull) a branch before a pull/merge request? Google Cloud Build/Run 触发合并特定分支的拉取请求 - Google Cloud Build/Run trigger upon Pull Request on merge with specific branch GitlabCI。 在主分支构建期间获取合并请求 ID - GitlabCI. Get merge request ID during master branch build 执行合并请求时如何在 GitlabCI 运行器中获取目标分支? - How to fetch the target branch in GitlabCI runner when doing merge request? 为什么 Gitlab 在您批准合并请求时会自动将目标分支合并到源分支? 如何禁用此行为? - Why Gitlab automatically merge target branch into source branch when you approve a merge request? How to disable this behaviour? 如何获取 Firebase Function 请求的来源 URL? - How do I get the origin URL of a Firebase Function request? 在管道事件源中使用“分支推送”方法计算“仅:更改:” - 合并请求 - Using the "branch push" method of calculate "only: changes:" in pipeline event source - merge-request 对于来自 bitbucket 的拉取请求被拒绝事件,我如何通过 webhook 触发代码构建? - How can I trigger codebuild via webhook for pull request declined event from bitbucket? 如何获取运行我的 Web 应用程序的容器的 ID/名称来满足当前用户请求 - How to get the id/name of the container in which my web application is running to serve the current user request 当主分支恢复时,如何将我的工作分支合并到主分支? - How to merge my working branch to main branch as main branch revert?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM