Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Clone not really a clone.(Trouble with cloning)
icon4.gif  Clone not really a clone. [message #1751505] Tue, 10 January 2017 22:05 Go to next message
bj cagnina is currently offline bj cagninaFriend
Messages: 3
Registered: January 2017
Junior Member
Using org.eclipse.jgit:org.eclipse.jgit:4.5.0.201609210915-r

First, I am cloning a repo like the following:

Git.cloneRepository()
.setURI("ssh://myrepo.git")
.setDirectory("/tmp/")
.setTransportConfigCallback(transport -> {
SshTransport sshTransport = (SshTransport) transport;
sshTransport.setSshSessionFactory(sshSessionFactory);
})
.setCloneAllBranches(true)
.call();

Then I enter the directory and perform (in command prompt), `git checkout pre-existing_branch_that_is_upstream` and get the following error:

error: The following untracked working tree files would be overwritten by checkout:
my_folder/my_file.json
Please move or remove them before you can switch branches.
Aborting


How can my branch be behind if it was a fresh clone? For sanity, If I clone the repo with git, everything is fine.

What exactly is JGit doing?
Re: Clone not really a clone. [message #1751625 is a reply to message #1751505] Thu, 12 January 2017 01:00 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 954
Registered: July 2009
Senior Member
What's the output of git status after cloning with jgit ?
Re: Clone not really a clone. [message #1751634 is a reply to message #1751625] Thu, 12 January 2017 07:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 28888
Registered: July 2009
Senior Member
I'm not an expert, but .setDirectory("/tmp/") looks suspicious to me. This folder is likely not empty so who knows what files are all there? Perhaps there are files from previous attempts to clone. Better would be to point at some directory location you know is empty.
Re: Clone not really a clone. [message #1751724 is a reply to message #1751634] Thu, 12 January 2017 21:52 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 954
Registered: July 2009
Senior Member
yep, this may cause issues. In EGit this is checked before clone is started.
Previous Topic:Failure in Eclipse installer (Oomph)
Next Topic:Importing a Gradle project from git sees the wrong gradle version
Goto Forum:
  


Current Time: Fri Oct 20 18:22:08 GMT 2017

Powered by FUDForum. Page generated in 0.01694 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software