git - 使用 (J)Git 获取 GitHub 存储库描述

标签 git github jgit

在 GitHub 中,每个存储库都可以有一个简短的描述,显示在 Code | Network | Pull Requests | Issues | Wiki | Graphs | Settings 下酒吧。

我可以edit the description on the GitHub webpage ,但我想使用 JGit 或 Git 来读取和更改它。这可能吗?

(首先我尝试阅读 .git/description ,但 GitHub 上的每个存储库似乎都包含相同的文本:

Unnamed repository; edit this file 'description' to name the repository.

.git/description在任何地方使用?)

最佳答案

.git/description 与 GitHub 存储库的描述字段无关。

您可以通过简单的curl获取该字段(即与git无关),遵循GitHub API for repositories :

curl https://api.github.com/repos/:owner/:reponame  2>/dev/null | grep description

# For instance
curl https://api.github.com/repos/VonC/compileEverything  2>/dev/null | grep description

您可以使用 PATCH http 方法轻松编辑它:

curl -u "$user:$pass" -X PATCH -d '{"name":"$reponame","description":"new_value"}' https://api.github.com/repos/$user/$reponame

(与“How do I rename a GitHub repository via their API? ”相同)

关于git - 使用 (J)Git 获取 GitHub 存储库描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15240969/

相关文章:

git - 如何动态确定 git-core 文件夹的位置?

Git 子模块 URL 不包括用户名?

混帐 : empty ident name (for <>) not allowed

java - 如何使用 JGit API 从父提交中获取树?

java - jGit - 如何将所有文件添加到暂存区

java - 使用 JGit 爬取 GitHub

git - 如何将整个 git 存储库移动到其他地方?

git - git 可以告诉我仓库何时从原点 pull 出吗

git - 永久删除提交

git - 是否可以在 GitHub 存储库上定义自己的语法?