如何使用Github API搜索特定分支上的内容
我正在使用搜索Github上远程repo上的内容。目前,我只能从默认的主分支中提取内容。除了master之外,还有什么方法可以下拉分支上的内容吗?这是我的代码片段,目前只从我的主分支中提取。谢谢你的帮助如何使用Github API搜索特定分支上的内容,github,github-api,Github,Github Api,我正在使用搜索Github上远程repo上的内容。目前,我只能从默认的主分支中提取内容。除了master之外,还有什么方法可以下拉分支上的内容吗?这是我的代码片段,目前只从我的主分支中提取。谢谢你的帮助 public class GitCompareTest { public static void main(String[] args) throws IOException { GitHub github = GitHub.connect(); GH
public class GitCompareTest {
public static void main(String[] args) throws IOException {
GitHub github = GitHub.connect();
GHRepository repo = github.getRepository(repo_name);
List<GHContent> articleContents = repo.getDirectoryContent(path);
for (GHContent content : articleContents) {
if (content.isDirectory()) {
PagedIterable<GHContent> childArticleContents = content.listDirectoryContent();
for (GHContent childArticleContent : childArticleContents) {
String childText = childArticleContent.getContent();
String.out.println(childText);
}
}
}
}
}
尝试getDirectoryContentString路径,使用分支名称作为ref的字符串ref。
分支名称本质上是git中特定提交的名称,ref是特定提交名称的git术语
免责声明:我还没有使用Kohsuke的GitHub库,我是从一般的git知识中提取的