GitHub + Gradescope Guide
This doc covers how to synchronize your local changes to your GitHub repo and how to turn in your GitHub repo as an assignment through Gradescope.
Basic Git
Tracking and pushing changes
Let's say you've edited your source code and now want to track the changes you've made. For example, maybe you edited main.cpp.
git status
Check the status of your repository by running git status
in the repository directory. If you have made changes, you should see a bunch of files marked as not staged for commit. In our case, we only edited main.cpp
, so that should be the only file listed here.
git add
Add your changes by running git add <file to add>
. You can also use a pattern instead of filenames, like git add *.cpp
to add all C++ source files. You can check the status of your repository again to verify that all changes you want to track have been added.
You should be tracking changes often enough that you shouldn't have many files to add. If you choose to use git add -A
which adds all changes at once, be sure to always check which group of files will be added in order to prevent unintended files from being tracked in the repository.
git commit
Once all files have been added, you can commit your changes to the branch you are currently working on (for most people, this will be the main/master branch). Run git commit -m <commit message>
with a short, informative message to add all tracked changes to the repository's history, also known as the tree.
If you forget to add the
-m
flag and get stuck on a vim page after running justgit commit
, you can quit the page by running:q!
to return to the terminal and retry committing.
git push
Push your changes to the origin remote (your personal GitHub Classroom repository) using git push origin <branch, typically master/main>
. You can omit origin <branch>
, but it is good practice to specify it to cement the idea that git push
will update a specific branch of the origin repository.
Commit (and push) your changes often! This will allow you to go back to working versions of your code if you have accidentally changed something and broken your functionality. GitHub also acts as a relatively reliable external backup for your code if for some reason your computer stops working.
For more information about GitHub, see our GitHub Guide.
Handing in assignments
This section covers how to hand in your work through Gradescope for both projects and labs in CS 1230.
- Navigate to your repository on GitHub to verify that your changes have been properly pushed.
- Once you are satisfied with the state of your repository, navigate to the CS 1230 course on Gradescope.
- Click on the assignment you'd like to hand in.
You will see two questions:
- GitHub Repository: Enter the HTTPS URL of your GitHub repository. This can simply be found by copying the URL when you visit the repository on GitHub. For example: https://github.com/BrownCSCI1230/projects-raster-jcarberry
- Commit ID: Enter the commit ID of the commit you'd like to submit. Read on to learn how to find the commit ID.
After entering the required information, click Submit.
Finding the commit ID
We require that you submit the commit ID corresponding to the commit you'd like to submit.
We ask for this instead of having you submit your code because we must ensure the version of your code which you demonstrate to your mentor TA in mentor meetings is the same version you submit to Gradescope. Gradescope unfortunately does not allow TAs to view the commit ID of the code you submit, so we ask that you submit the commit ID to us directly.
During your mentor meetings, we verify that the commit ID you submitted to Gradescope matches the commit ID of the code you demonstrate.
In order to find the commit ID, you can either use the GitHub website or the command line.
GitHub website
- Navigate to your repository on GitHub. Make sure you are on the correct branch. Click on the button as shown below to see the commit history.
- Find the commit you'd like to submit and click on the clipboard icon to copy the commit ID.
Command line
- Navigate to your repository on GitHub. Make sure you are on the correct branch. Run
git log
to see the commit history.
Find the commit you'd like to submit and copy the commit ID.