For example, the Github repo URL for my Java samples is https://github.com/tomjoht/eclipse-java.git.

On your computer, open a command prompt and type pwd to see your present working directory. Then create a subdirectory called “projects” or something similar by typing mkdir projects. Then cd to this projects directory.

Tip: Although you can put your directory anywhere, it’s most convenient to use a subdirectory under the default directory your command prompt opens to.

In the directory where you want to clone the repository, type the following, replacing {repo_url} with the actual URL of the Github repository (such as https://github.com/tomjoht/eclipse-java.git).

git clone {repo_url}

All the files download when you clone the repo.

Add the Java projects to the repository:

git add .

The . adds all file types. (It’s not a typo there.)

Commit the files:

git commit -m "your commit msg"

If you just type git commit you’ll be prompted to add a commit message in a text editor using VIM.

Push the files to the repository:

git push

Download the Java projects from Github

If you’re sharing Java project files, this section is relevant. If you’re just sharing regular files, skip this section.

Participants who want to grab the files from the Github repo follow these steps. If you created this repository, you don’t need to follow these steps.

cd to a convenient directory, such as as users/projects.* In the directory where you want to clone the repository, type the following, replacing {repo_url} with the actual URL of the Github repository (such as https://github.com/tomjoht/eclipse-java.git).

git clone {repo_url}

All the files download when you clone the repo. To get updates to the repo at a later time, use the pull command:

git pull

Tip: To see a list of git commands, type git --help.

Import the projects into Eclipse

In Eclipse, go to File > New > Java Working Set and create a working set called “Java Tutorials” (or something appropriate). A working set allows you to filter the projects shown in Eclipse’s Project Explorer pane.

Go to File > Import > General and select Existing Projects into Eclipse.

Next to “Select root directory,” browse to the cloned repository on your computer where you downloaded all the files from Github. Then select Open.

Select the Add projects to working set check box, and then select the working set you created.