下面的代码正常工作,但是问题是只有master分支正在推送,但是我也想推送我的其他分支。
String pushData(String name) {
migerateRepoName="contentDataa";
String response = null;
String url = pushRepoUrl + migerateRepoName + ".git";
try {
Git git = Git.open(new File(localRepoPath));
RemoteAddCommand remoteAddCommand = git.remoteAdd();
remoteAddCommand.setName("origin");
//remoteAddCommand.setUri(new URIish("git@github.com/contentDataa.git"));
remoteAddCommand.setUri(new URIish(url));
remoteAddCommand.call();
git.add().addFilepattern("*").call();
CommitCommand commit = git.commit();
commit.setMessage("Migration Initial Commit");
commit.call();
PushCommand pushCommand = git.push();
pushCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider("userName", "password"));
pushCommand.setPushAll();
pushCommand.call();
response = "Successfully";
} catch (Exception e) {
response = "Exception Occur While Push Data URL :" + url;
e.printStackTrace();
}
return response;
}