These instructions will guide you through the process of setting up Codespaces, an online IDE. IDE stands for Integrated Development Environment, which is a program that software developers use to write code. You can use any text editor to write code, but an IDE makes it much easier.
Think of Codespaces like Microsoft Word for code. You can write a really long essay in Notepad if you want to, but you'll almost always prefer to do it in Word or Google Docs.
Create a GitHub account. GitHub is a free service that stores code for you in the cloud. It is the industry standard for storing and sharing software code. Think of it like Google Drive for code!
For your username, <firstname>-<lastinitial>-ephrata-teals
format. So, if your name was Jane Doe, your username would be jane-d-ephrata-teals
.
- In a new tab in Chrome, go to https://github.com
- Click "Sign up" in the top right corner
- Enter your username in the
<firstname>-<lastinitial>-ephrata-teals
format - Enter your
@ephrataschools.org
email - Choose a password
- Solve the verification puzzle
- Click "Create account"
- In a new tab in Chrome, go to GMail. You should see an email from Github asking you to verify your email address
- Open the email and click "Verify email address"
In this step you'll be copying an existing Github repository to your own account. You can think of a repository as a special kind of folder for code. It's actually much more complicated (and powerful) than that, but you'll learn about all of that another time.
-
In a new tab in Chrome, go to https://github.com/DataSnowman/ephrataTEALS2021
-
Click on "Fork" in the top right corner
-
If you are asked "Where should we fork EphrataTEALS?", click on your new Github username
You now have a copy of the EphrataTEALS repository in your GitHub. This is what you should see:
My username was darsch so the repository shows up as darsh/ephrataTEALS2021
.
Yours should be <firstname>-<lastinitial>-ephrata-teals/ephrataTEALS2021
.
Configure Codespaces and GitHub settings and remote for fork
Click on Code and select Open with Codespaces
Click on + New codespace on current branch
When the Codespace opens it should look something like this
This step will involve entering some commands into the terminal, or command line. If this if the first time you've used a terminal, it can be intimidating. Don't worry! Just follow the directions and copy and paste the commands exactly. When an instruction says to enter a command, it means to type (or paste) the command, and then press the Enter key to execute it.
-
Open a terminal in your Codspace using the keyboard shortcut
Ctrl + `
(you can also go to the menu in the top left and select Terminal > New Terminal)
Make sure it is a bash shell
- In the terminal, type or paste the following command and hit Enter:
pwd
- Now enter the following command (remember, "entering" a command means typing or pasting it into the terminal, then pressing Enter to execute it):
git status
Your terminal should now look like the following, except it will say "ephrataTEALS2021" instead of "TEALS1":
- Enter the following command, replacing
<GitHubusername>
with the<firstname>-<lastinitial>-ephrata-teals
username you created earlier:
git config --global user.name "<GitHubusername>"
- Confirm that you have set the username correctly by entering the following command:
git config --global user.name
- Enter the following command, replacing
email@example.com
with your@ephrataschools.org
email:
git config --global user.email "email@example.com"
- Confirm that you have set the email address correctly by entering the following command:
git config --global user.email
- Enter the following command:
git remote -v
- Make sure that your terminal displays the following:
> origin https://github.com/<firstname>-<lastinitial>-ephrata-teals/ephrataTEALS2021 (fetch)
> origin https://github.com/<firstname>-<lastinitial>-ephrata-teals/ephrataTEALS2021 (push)
> upstream https://github.com/DataSnowman/ephrataTEALS2021.git (fetch)
> upstream https://github.com/DataSnowman/ephrataTEALS2021.git (push)
If this is the case go to step 12
If it only shows the following:
> origin https://github.com/<firstname>-<lastinitial>-ephrata-teals/ephrataTEALS2021 (fetch)
> origin https://github.com/<firstname>-<lastinitial>-ephrata-teals/ephrataTEALS2021 (push)
Then
- Enter the following command as-is (do not replace the username):
git remote add upstream https://github.com/DataSnowman/ephrataTEALS2021.git
- Enter the following command again:
git remote -v
- Finally, enter the following command:
git pull upstream main
Run your CodespacesBeta.java program!
- In
sampleCode >
, findCodespacesBeta.java
. The contents of the file should look like this:
package sampleCode.GitHubCodespacesTest;
public class CodespacesBeta {
public static void main(String[] args) {
String x = "Welcome Back !!!";
System.out.println(x);
}
}
- Codespaces may automatically open some other tabs. If this happens, just close them and return to
CodespacesBeta.java
. - On the sidebar, click the "Run" button (the one with the play button and the little bug):
- Click "Run and Debug". Again, Codespaces may automatically open some other tabs. If this happens, close them and click "Run and Debug" again.
- You should see the following output in the terminal:
Congratulations! You just ran your first program!
Copy the GitHubCodespacesTest folder and paste to studentWork folder and then change the code
- Copy the GitHubCodespacesTest folder and paste to studentWork folder
- In
CodespacesBeta.java
, find the line that readspackage sampleCode.GitHubCodespacesTest;
- Change sampleCode to studentWork so it reads
package studentWork.GitHubCodespacesTest;
- In
CodespacesBeta.java
, find the line that readsSystem.out.println("Welcome Back !!!");
- Replace
Welcome Back
withIts a new school Year
(or anything, really! You could writeHappy School Year <your dog's name>
orTime to get school supplies
) - Click the "Run and Debug" button again
- You should see the new greeting in the terminal. You just wrote your first piece of code!
- To save your work, enter the following sequence of commands in the terminal:
git add -A
git commit -m "Modified CodespacesTest.java"
git push origin main
At the beginning of each class, after opening your Codepsace, you will open a terminal window (with Ctrl + `
or using menu and going to Terminal > New Terminal). Then you will enter the following command:
git pull upstream main
This command gets any new code from the instructors that you will need for the class that day.
At the end of every class, you will run the following sequence of commands:
git add -A
git commit -m "<description of your work for the day>"
git push origin main
This will save your changes by pushing them changes to your forked repository.