Clone Starter from GitHub
Once we have accepted the assignment on GitHub classroom and have access to the repository, we can “clone” it in Codio, allowing us to access any starter code and then add our own code as we continue to work through this example project. This project doesn’t include any starter code, but we’ll go ahead and do this step first, just like we would with any other project.
Find GitHub Repository URL
At this point, you should have access to a repository page that looks like this:
On that page, we need to get the SSH URL of this repository. We can find it by clicking the green Code button in the upper right. On the box that appears, make sure you select the SSH option to get the SSH URL. It should look similar to this:
The SSH URL should begin with
firstname.lastname@example.org:. If it starts with
https:// then you need to select the SSH option. Once you have the correct URL, select it and copy it to your clipboard.
Clone Project in Codio
Next, we need to open a Linux terminal in Codio and use the
git command line tool to clone that repository in Codio. Make sure your terminal is in the
workspace folder by running this command first:
It should be in that folder by default, but it is always a good idea to check by either running the command above or looking at the end of the command prompt.
Then, we will use a command structured like this to clone the repository. do not run this command - keep reading:
git clone <SSH URL> <language folder>
In that command, replace the
<SSH URL> portion with the SSH URL you copied from GitHub above. Also, replace the
<language folder> section with the name of the folder for the programming language you wish to use.
For example, if I would like to complete this exercise using the Java programming language, my command would look like this:
git clone email@example.com:K-State-Computational-Core/example-1-hello-real-world-russfeld-student.git java
For Python, I would use:
git clone firstname.lastname@example.org:K-State-Computational-Core/example-1-hello-real-world-russfeld-student.git python
Of course, your SSH URL will be different, so you must adjust the required command above to meet your needs. Basically, just type
git clone, then a space, then paste in your SSH URL, and then another space, followed by the name of the programming language that you’d like to use. That’s all it takes!
When I run that command, I’ll get output that looks like this:
If this is the first time you’ve used
git in this Codio project, you’ll have to type
yes and press enter at the prompt to accept the key for
github.com. Once you do that, then the rest of the command will complete and you’ll see the following output:
Since I used
java as the last part of that command, I should now see at least two new items in the
java folder in the Codio file tree:
If you choose
python, you’ll probably see the same items inside of the
python directory instead. The
.github folders contain information about the repository and the classroom assignment, and should be left alone. DO NOT DELETE OR MODIFY THESE FOLDERS! You may notice that they are not present in many of the screenshots in this assignment, just as a reminder to ignore them completely.
If you accidentally forget to specify a folder at the end of the
git clone command, or specify the wrong folder, your repository may not be in the
python folder that already exists in Codio. In that case, there are a couple of remedies you may try:
- Delete the folder that was created in error, and try the command again with the correct folder name.
- Delete the existing
pythonfolder, and rename the new folder to the correct name.
If you try to clone a repository into a folder that is not empty, you’ll get an error message. In that case, it is best to completely delete the folder and try again. If the folder doesn’t exist, the
git command will create it for you.
If you receive an error message stating “Could not read from remote repository,” double-check your URL and try again. If it still doesn’t work, let the instructor know. There is a chance that the instructor simply needs to authorize the Codio SSH keys on the new GitHub classroom instance. We have to do this each semester, and it can easily be forgotten. You may earn some bug bounty points for letting us know about this!
If you were able to successfully clone the project from GitHub Classroom into Codio, you are ready to begin coding! From here on out, the guide will refer to the
python folders directly, assuming that you’ve properly cloned the assignment from GitHub correctly.
The next parts of this project are different for Java and Python. Click the link below to jump to the correct section for your language. You can also use the links in the menu to the left.