想在git API的帮助下使用所有不同的分支将我的本地仓库推送到git中

时间:2018-08-03 11:31:58

标签: java bitbucket bitbucket-api

下面的代码正常工作,但是问题是只有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;
    }

0 个答案:

没有答案