[英]What are the requirements to connect GitHub by using GitHub api and java
[英]How to connect to github repository using java and github api
我需要使用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);
沒用
請給我一個可行的例子。 那真的很有幫助。
您可以在centic9/jgit-cookbook
找到有關以下方面的工作示例:
Repository repository = createNewRepository();
git push
(可以推送您添加/提交的任何文件,是否為JSON)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.