Prepared by Nasser Giacaman for SOFTENG 206, SOFTENG 281, and MECHENG 270
These instructions are provided to help you use GitHub in this course.
Follow these instructions carefully. There are a couple of issues you might encounter, and we warn of these in the respective steps.
If you encounter any problems, check the FAQ section below.
If you don’t already have accounts to GitHub and Repl, you will need to create them.
Your lecturer will share with you an invitation link for GitHub Classroom. Each assignment will have its own invitation link.
The first step involves cloning the GitHub assignment to your own account. This will create a private copy of the code provided by the lecturer, and will add it to your own GitHub account.
Click on the assignment invitation link provided by your lecturer.
If this is the first time you access this course’s GitHub invitation, you might be asked to select your name from the course roster. Select your name/identity if prompted.
Click the Accept this assignment button as shown below:
You will see the following processing taking place, wait for them to complete:
When you see the following page, click URL of the cloned repository as shown below:
If you see the following page, you have successfully cloned the assignment to your own GitHub repository:
Follow the following instructions if you need to work on your assignment (or test your assignment) using the online Repl IDE.
Sign into Repl using your GitHub credentials. You should see the following:
Now that you are logged into your Repl account, go back to your GitHub repository and click the Work in Repl.it badge as shown below:
When you click on the Work in Repl.it badge and it starts loading correctly, this step may take a few seconds. You will most likely see the following as everything loads:
Still loading…
Once you see the prompt ( ) in the console, you are done and ready to code in Repl!
Even if this prompt isn’t visible, it might still be ready (try and click the Run button).
Once you have your Repl workspace created, you can explore the Repl online IDE.
From the left menu, you can navigate to My Repls. This shows you a list of all your Repls.
This is correct:
This is wrong:
Go back to your Repl project workspace by clicking the name of your project from the My Repls, until you see the project as below.
The Repl IDE is simple to use:
Further to this, frequent commits will protect you in a number of ways:
If you make devastating edits to your code, you can easily roll back to a prior version.
If someone copies your work, your history of commits will back up your story that you did your own work.
If your laptop or power fails 2 minutes before the deadline and you do not submit on time, you have your commits to show you didn’t edit the code after the deadline.
Learn an essential software development tool.
… and plenty more!
Committing to your GitHub repository is easy from within Repl. Follow the following 3 steps:
Open the GitHub Version Control menu inside your Repl project.
Add a meaningful message to represent what changes you made and are committing here.
Press the commit & push button.
You should immediately see the updated information, listing the commit you just made:
You can double check.
The great thing about using Repl to push your commits, is you don’t need to install any software (the whole idea is that git is integrated into the online Repl IDE).
But if you’re going to be installing and using your own local IDE (with compiler etc), that’s great also. In this case, it’s recommended to use the command line to make commits to your GitHub repository.
First, you will need to install the git
command line tool. There are plenty of tutorials online to do this, depending on your operating system. You might need to configure your username, password etc. Again, Google is your best friend.
Go to your GitHub repository page:
Press the Code button.
Click on the clipboard icon to copy the URL.
Determine where you would like to manage your repositories. Go to that folder.
Type the following command, using the URL you got from the earlier step above:
git clone URL-TO-REPO
If all goes well, you should be able to see a new folder (with the name of your repository). This folder is known as the local repository, which effectively is your local copy of the (otherwise remote) repository that is stored on the GitHub server.
When you edit your code, or add a new file, you will need to stage (git terminology) these to be ready to push to the repo.
Go inside the folder that contains the repository.
Open the command line so that the working directory is inside the repository.
Type the following command, and it should tell you what changes are local (on your computer, and not inside the remote repository).
git status
Type the following command to add all changes, including new files:
git add .
If you want to be selective about what you want to stage to commit, you can be explicit:
git add main.cpp
Commit all that is staged by typing the following:
git commit -m “Added goodbye print”
-m
option and need to get out of vim
:
While the commit part is done, the commit is only made locally (i.e. your local repository). You still need to push this to the remote repository:
git push -u origin main
master
instead of main
, i.e.: You can double check.
If you will be installing your own local IDE to use, and don’t want to use the command line to push your commits, then you can look around for a git GUI client. There are plenty of options here, depending on your operating system and personal preferences (so maybe Google around first). This list is by no means exhaustive:
GitHub Desktop is popular for Windows and macOS.
For Linux, shop around.
Most popular IDEs will also have git integration (or at least plugins/add-ons you can install), so you can commit directly from within the IDE.
If you want to double-check the commit went through to GitHub correctly, do the following.
From your GitHub assignment repository, click on the commits link:
You should be able to see the commit details listed here also:
Coming soon… In the meantime, ask on Piazza.