I want to push and comit some changes in my own repository on github via code with JGit
try {
Git git = Git.open(new File(pathToFolder));
git.add().addFilepattern(".").call();
git.commit().setMessage(commitMessage).call();
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username,password);
System.out.println(credentialsProvider);
git.push().setRemote("https://github.com/my/repo.git").setCredentialsProvider(credentialsProvider).call();
System.out.println("File pushed successfully!");
} catch (IOException | GitAPIException e) {
e.printStackTrace();
}
I tried this code but the code keeps giving me an error:
org.eclipse.jgit.api.errors.TransportException: https://github.com/username/repo.git: not authorized
i know that i have the permits to do so becouse is a repository i created and the username and password i utilized were the one from my account
my repository is also public
Thanks