Eclipse - how to git clone --depth 1

1.3k Views Asked by At

I have to import a quite big (bitbucket) git repository in Eclipse. Right now Eclipse is stuck cloning from an hour. To speed up things I'd like to clone it in "shallow" mode (just taking the last commit).

I tested this with the CLI git clone --depth 1 https://bitbucket.myco.local:8443/scm/big/quite-big-project.git and it worked well: it took less than 2 minutes. Anyway I have to clone the project into eclipse and have no idea about how to set the depth in Eclipse's git import project wizard.

3

There are 3 best solutions below

3
mbooth On BEST ANSWER

Unfortunately, JGit, the pure Java implementation of git used by Eclipse does not yet support the --depth option:

$ jgit clone --depth=1 https://github.com/eclipse-linuxtools/org.eclipse.linuxtools.eclipse-build.git
fatal: "--depth" is not a valid option

There is bug open for it over at bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475615

I would recommend cloning it via the normal git command line, and then using the "add existing local repo" button from the Git perspective:

Click here to view a screenshot

0
DDS On

I worked-around like this (in a way similar as what suggested @mboot):
1> I cloned the repository with CLI and --depth 1 option
2> I followed the procedure of import from git using "filesystem" protocol
3> Unbound the "filesystem" origin (git remote remove origin)
4> Added the "actual" remote git remote add origin https://bitbucket.myco.local:8443/scm/big/quite-big-project.git
5> Hoped for the best

0
William Chen On

android 13 can use jgit 6.3.0 ( shallow depth ) now

(Because jgit 6.3.0 user OutputStream.transferTo method ) see android 13 api 33