Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Github API搜索特定分支上的内容_Github_Github Api - Fatal编程技术网

如何使用Github API搜索特定分支上的内容

如何使用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

我正在使用搜索Github上远程repo上的内容。目前,我只能从默认的主分支中提取内容。除了master之外,还有什么方法可以下拉分支上的内容吗?这是我的代码片段,目前只从我的主分支中提取。谢谢你的帮助

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知识中提取的