【问题标题】:Is there a way to determine if my local clone is a fork of some github repo?有没有办法确定我的本地克隆是否是某个 github 存储库的分支?
【发布时间】:2020-02-24 00:02:39
【问题描述】:

更具体地说,我如何判断磁盘上的 repo 的来源是否是某个 repo 的分支?我在想它应该是一些 API 调用,但我不确定。我可以依赖“remote.upstream.url”吗?

【问题讨论】:

  • 我想您应该在本地分支的开头有匹配的提交 ID。

标签: git github git-clone git-fork


【解决方案1】:

您可以使用GitHub API for Repositoriesget a specific repo

GET /repos/:owner/:repo

(您可以使用curl call from command line

JSON 答案将包含一个“fork”字段:值 true 或 false。

【讨论】:

  • 啊哈!我可以问我的 repo 它是什么的一个分支。所以:owner/:repo 来自git config --get remote.origin.url,在"parent" 中寻找"fork": true"full_name:"。谢谢。
  • @mpersico 没错。或者,正如我在stackoverflow.com/a/32991784/6309git remote get-url origin 中提到的那样。
  • 啊哈2!我今天会用这个宝石更新。每次我的机器收到一个新的 git 包时,我都会尝试阅读发行说明,但有时我会错过它。
猜你喜欢
  • 2021-07-22
  • 2022-01-20
  • 2021-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-02
  • 2021-12-02
相关资源
最近更新 更多