简体   繁体   中英

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.

I saw some examples using JGit and some other references like 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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM