[英]How to connect to github repository using java and github api
I need to create remote Github repository using java (Using my credentials) and I need to push .Json file to that repo. 我需要使用java创建远程Github存储库(使用我的凭据),并且需要将.Json文件推送到该存储库。
I saw some examples using JGit and some other references like http://www.codeaffine.com/2015/11/30/jgit-clone-repository/ 我看到了一些使用JGit的示例以及其他一些参考,例如http://www.codeaffine.com/2015/11/30/jgit-clone-repository/
I've written small code 我写了小代码
GitHubClient client = new GitHubClient();
client.setCredentials("username", "password");
RepositoryService service = new RepositoryService(client);
Repository repo=new Repository(); repo.setName("newRepo");
service.createRepository(repo);
It isn't working 没用
Please help me with a working example. 请给我一个可行的例子。 That would be really helpful. 那真的很有帮助。
You will find working examples in centic9/jgit-cookbook
, regarding: 您可以在centic9/jgit-cookbook
找到有关以下方面的工作示例:
Repository repository = createNewRepository();
git push
(which can push any file you have added/commit, JSON or not) git push
(可以推送您添加/提交的任何文件,是否为JSON)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.