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