Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a specific project from github

Tags:

github

eclipse

How to import a specific project from github ? I dont want to clone the entire repository I just want to clone only a portion of repository .

For eg this url https://github.com/eugenp/tutorials has many projects but I just want to clone only spring-boot-crud project . Here is the url for spring-boot-crud project. https://github.com/eugenp/tutorials/tree/master/spring-boot-modules/spring-boot-crud

Thank you .

like image 508
RajGopalbh4 Avatar asked Oct 26 '25 21:10

RajGopalbh4


1 Answers

You can look into a git sparse-checkout: that command is made to checkout only part of a Git repository. This assume the latest Git 2.26 though.
And I mean Git-core, as in Git SCM, not Egit (which does not support the new sparse-checkout command)

Even though the command is new and still experimental, it should be useful in your case.

git clone --no-checkout /url/a/repo
cd repo
git sparse-checkout init --cone
git sparse-checkout set spring-boot-modules/spring-boot-crud

Then open the relevant project in your Eclipse.

Create a project in the Git repo (.project, in the root folder of your repo)

That will give you:

git clone -n https://github/git/git git2
cd git2
git sparse-checkout init
git sparse-checkout set Documentation

At this point, you have the repository git/git with only the folder Documentation checked out (everything else is not in the working tree)

# create an empty project in C:\path\to\git2 in Eclipse

Sparsed-checkout repo in Eclipse

As you can see, all the other files not checked out are not displayed in the Git staging view. Only the ones currently checked out and modified are listed.

The first step must be done in command-line because JGit does not support the sparse-checkout directive (see but 383772 and change 33)

like image 113
VonC Avatar answered Oct 30 '25 12:10

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!