|Re: [jgit-dev] Migrating from Jgit 1.0 to 1.1|
Hi,I could not make it work. Just to simplify things, I all want to do with Jgit 1.1 is this:$ git brach newbranch -t origin/fooCreate a local branch tracking to a remote branch.Thanks in advance,Eduardo Falcão--2011/9/27 Matthias Sohn <matthias.sohn@xxxxxxxxxxxxxx>
--2011/9/27 Eduardo Falcão <edu.falcao@xxxxxxxxx>
Hi,I'm working in a project with Jgit 1.0 and I want to migrate to 1.1, but I'm stuck in one problem. Let me explain the workflow:1) Let's assume that in my remote there are 3 branches: master, b1 and b2.2) Clone remote repository with clonecommand passing the branch "master". This way my local repository is created and the local branch "master" is linked to the remote master.cc.setURI(remoteSSHConnection);cc.setDirectory(new File(localRepoPath));cc.setBranch("refs/heads/master");cc.setCredentialsProvider(credential);cc.call();With JGit 1.0, I could run clonecommand again in the same local repository passing "refs/heads/b1", and a local branch is created linked to remote. But in 1.1 an error occurs, saying that I cannot clone into a folder that already exists and is not empty. What do I have to do? All I want is to checkout in a branch that not exists locally, but it has to track the remote branch and have the same name.you can't clone into an existing repo, if that worked in 1.0 this was a buginstead try the following:- fetch the branch e.g. "foo" you want to have locally using refspecrefs/heads/foo:refs/remotes/origin/foothis creates the remote tracking branch refs/remotes/origin/foo- create a local branch starting from this remote tracking branch and set theupstream configuration, you can do that using CheckoutCommandusing setUpstreamMode()- if you want to fetch updates and update this local branch run pull,the upstream configuration has established a tracking relationshipso pull knows where to merge the new changes it has fetched forfoo from the remote repositoryuse the corresponding commands from org.eclipse.jgit.api andsee the corresponding tests in bundle org.eclipse.jgit.test forexamples.ps: With original git command line, if i checkout in a branch that not exist locally but exists in remote, it is automatically created locally and linked to remote
which command do you use for that ?
Back to the top