Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[egit-dev] How to merge (programmatically) with a remote repo?

Hi

I currently try to merge a local repo with a remote one, but I currently fail. I'd appreciate a lot if you could gimme some pointers :)

I first init a local repo:

        InitCommand init = Git.init();
        init.setDirectory(repositoryFile);
        init.setBare(false);
        Git git = init.call();
        Repository repository = git.getRepository();

 and then add a remote to it:

        StoredConfig config = repository.getConfig();
RemoteConfig remoteConfig = new RemoteConfig("ssh://.....", "myRemote");
        remoteConfig.addURI(uri);
        remoteConfig.update(config);
        config.save();

and then I'd like to merge my local repo with the remote (???):

        ObjectId objectId = repository.resolve(remoteName);
git.merge().include(objectId).setStrategy(MergeStrategy.OURS).call();

I fail when trying to tell the merge command to merge with the remote. I'd appreciate any points a lot.

Thanks!
André




Back to the top