Skip to content

Instantly share code, notes, and snippets.

@klaeufer
Last active March 21, 2022 16:56
Show Gist options
  • Save klaeufer/11cf4a13b5a1634d7c3991cc07ddc408 to your computer and use it in GitHub Desktop.
Save klaeufer/11cf4a13b5a1634d7c3991cc07ddc408 to your computer and use it in GitHub Desktop.
How to copy a GitHub Java project into your own workspace

How to copy a GitHub Java project into your own workspace

This brief howto discusses several ways to copy a GitHub Java project into your own workspace so you can edit, compile, and run/test it.

Method 1 (highly discouraged)

This method is highly discouraged because it is tedious and error-prone.

  1. Create a new project in your development environment, such as IntelliJ IDEA.
  2. For each file in the GitHub project you are copying, create a file in your new project, then copy and paste the contents of the original file to your local file.

Common errors introduced by this method are wrong project folder structure, missing files, missing code, etc.

In addition, if the code depends on any external libraries, you will need to add these to the project manually as described here.

When using the last three methods, your development environment should automatically recognize any external library dependencies based on the Maven project configuration file (pom.xml).

Method 2 (less bad)

  1. Look for the green button in the upper right of the main project page on GitHub.
  2. Press the button.
  3. Choose "download as Zip".
  4. Move the downloaded zip file to your local project folder.
  5. Extract the zip file in your file explorer/finder to a folder.
  6. In your development environment, choose "open project" or similar, navigate to your local project folder, and open the subfolder extracted from the zip.

This method is suitable if you want to submit your project as an exported zip file.

Method 3 (better)

  1. Look for the green button in the upper right of the main project page on GitHub.
  2. Press the button.
  3. Choose "clone" and "https", then press the copy button (or copy the project URL shown).
  4. In your development environment, choose "get from VCS" or similar, enter the copied repository URL in the corresponding field, and press "clone".

Note that this method still requires you to submit your project as an exported zip file.

Method 4 (best)

  • Follow the process described here.
  • When using GitHub classroom (stay tuned), the same process still applies, except that you no longer need to import the repository yourself because GitHub classroom does this automatically.
  • Now your local work gets pushed to your hosted GitHub repository, and you only need to submit that repository's URL for us to have access to your work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment