如何使用java和github api连接到github存储库

时间:2017-07-04 16:37:33

标签: java github-api git-remote

我需要使用java创建远程Github存储库(使用我的凭据),我需要将.Json文件推送到该存储库。

我看到了一些使用JGit和其他引用的示例,例如http://www.codeaffine.com/2015/11/30/jgit-clone-repository/

我写了小代码

GitHubClient client = new GitHubClient(); 
client.setCredentials("username", "password"); 
RepositoryService service = new RepositoryService(client); 
Repository repo=new Repository(); repo.setName("newRepo"); 
service.createRepository(repo); 

无效

请帮我一个有效的例子。这将非常有用。

1 个答案:

答案 0 :(得分:0)

您可以在centic9/jgit-cookbook中找到有关以下内容的工作示例: