I need a piece of code which can pull
from origin and merge
with local repo. I tried with local repo which can get the last commit and revision. however not able to pull
the changes from origin.
File gitWorkDir = new File(gitDir);
Git git = Git.open(gitWorkDir);
Repository repo = git.getRepository();
UsernamePasswordCredentialsProvider user = new
UsernamePasswordCredentialsProvider("username", "password");
PullCommand pullCmd = git.pull();
pullCmd.setCredentialsProvider(user);
pullCmd.call();
ObjectId lastCommitId = repo.resolve(Constants.HEAD);
log.info(lastCommitId);
where gitDir
is my local Repository Dir.