gpt4 book ai didi

git - 如何在不调用 Github API 的情况下获取 GitBash 中特定分支的现有 Pull Request ID 和 Url?

转载 作者:太空狗 更新时间:2023-10-29 14:16:33 24 4
gpt4 key购买 nike

我需要找到问题中描述的确切情况的解决方案。

我只有一个功能分支 ID,我需要在 GitBash(2.20.1) 或终端上获取 Pull Request ID 或 Url,而无需调用 Github API..

我已经试过了,但它不适用于每个分支或总是,不知道为什么。

git ls-remote origin 'pull/*/head' | grep -F -f <(git rev-parse HEAD) | awk -F'/' '{print $3}'

最佳答案

but it doesn't work for every Branch or always,

那是因为:

  • 要么你的分支根本不是 GitHub PR 分支的一部分
  • 或者您的分支机构有新的本地提交尚未推送到您的 PR 分支机构,这意味着 grep(您的本地 HEAD 提交)只能失败。

代替 grepping,尝试检查 PR 分支 HEAD 是否是您当前分支历史的一部分。
参见“How to list branches that contain a given commit?

git fetch origin +refs/pull/*/head:refs/remotes/origin/pr/*
git branch -a --contains <commit>

如果你有任何 /pull/ 分支,你将获得你想要的 PR。

关于git - 如何在不调用 Github API 的情况下获取 GitBash 中特定分支的现有 Pull Request ID 和 Url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53877173/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com