Сообщение об ошибке JGit:
Код: Выделить всё
Exception in thread "main" org.eclipse.jgit.api.errors.TransportException: https://github.com/USERNAME/testing.git: not authorized
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:249)
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:325)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:191)
Код: Выделить всё
public static void main(String[] args) throws GitAPIException, IOException {
CredentialsProvider credentialsProvider
= new UsernamePasswordCredentialsProvider( "XXXXXXXXXX", "XXXXXXXXXX" );
Git git = Git.cloneRepository()
.setURI( "XXXXXXXXXX" )
.setDirectory(new File(System.getProperty("user.home") + File.separator + "git_test"))
.setCredentialsProvider( credentialsProvider )
.call();
File file = new File( git.getRepository().getWorkTree(), "file" + new Object().hashCode() );
file.createNewFile();
git.add().addFilepattern( file.getName() ).call();
git.commit().setMessage( "Add file " + file.getName() ).call();
git.push()
.setCredentialsProvider( credentialsProvider )
.call();
}
}
Код: Выделить всё
this.git = Git.init().setDirectory(new File(folderPath)).call();
this.git.add().addFilepattern("temp.txt").call();
this.git.commit().setMessage("Modified temp.txt").call();
this.git.push().setRemote(textfield.getText())
.setCredentialsProvider(new UsernamePasswordCredentialsProvider("XXXXXXX", "XXXXXX"))
.call();
Подробнее здесь: https://stackoverflow.com/questions/758 ... ansportexc
Мобильная версия