Submitty Server Version Control Repositories
-
If your instructor has prepared a repository for you, you will see how to clone the initial repository when you click to submit your assignment. It will look something like this:
git clone https://submitty.myuniversity.edu/git/s19/csci1200/hw1/myusername SPECIFY_TARGET_DIRECTORYCopy and paste this line into a terminal on your computer. Replace
SPECIFY_TARGET_DIRECTORYwith a path and directory name on your computer. Run the command. -
You will be prompted to enter your username and password.
NOTE: You may be required to use an Authentication Token instead of your password.
If the command fails, check the assignment instructions. Your instructor may not have created the initial repositories yet and you should check back later. Contact your instructor if you think the repositories should be available now.
-
Your initial repository may be empty (no branches and no files). If this is the case you should do your work in the
mainbranch. This may happen by default, or you may need to first type:git checkout -b mainto create and checkout the initial
mainbranch. Create/copy files/directory structure into the repository directory following the assignment instructions.Note: Please also read the section below on Instructor Provided Code.
Public Repositories (e.g., Github)
TODO:
Private, Student-Created Repositories (e.g., Github)
TODO:
External, Private, Instructor-Created Repositories (e.g., Gitlab or Github Classroom)
NOTE: These instructions will help you fork and access the repository created by your instructor. Before you follow these instructions, if you are using private repositories, you will need to add a SSH key to your git system if your instructor has not already.
-
Navigate to the course repository specified by your instructor. Duplicate this window, and leave one copy open, as you will come back to it in step 4.
-
Fork the repository, under your namespace.
-
Clone the repository to your IDE using the ‘Clone with SSH’ option. Using Github:
git clone git@github.com:myusername/student101.git -
Set the upstream repository using:
git remote add upstream SSH_URLReplace
SSH_URLwith the ‘Clone with SSH’ URL from the course repository window from step 1. -
To pull changes from the upstream repository, use the commands:
git pull git fetch upstream git checkout main git merge upstream/mainReplace
mainwith your modified branch if the name is different. Use the instructions listed below to push your changes.
Committing Your Work
-
To check what changes you’ve made since your last commit, run:
git statusMake sure you’re on the
mainbranch. You’ll see messages about any files you have “modified”, files you may have “deleted”, files that are “new” (you’ve already indicated they should be added to the repository), and files that are “untracked” (and will be ignored, unless you add them to the repository). -
If you’ve created a new file and you do want it to be in the repository, you need to tell git about it:
git add FILENAME -
Confirm the details of the edits you’ve made to the above files:
git diff -
When you’re happy with the contents that you’re committing, type:
git commit -m 'SPECIFY YOUR COMMIT MESSAGE'Be sure to write a good commit message, this will be entered in the log and is helpful if you ever need to revert your work!
Pushing your Commits to the Server and Submitting Your Assignment
Currently your work is only on your local machine.
-
If there have been edits to your repository on the server, you may need to first pull those changes to your local machine:
git pullNote: Please also read the section below on Instructor Provided Code.
Note: Please also read the section below on Team Work with GIT.
-
Then to push your work to the server:
git pushIf you are on the
mainbranch on your local machine, this will push your local main branch to the main branch oforigin, which is the machine from which you originally cloned the repository.NOTE: Yay! Your work is now backed up. If your local machine explodes, you can download your code from the server.
However, your code is not yet submitted, and won’t be automatically tested/graded by Submitty. And your instructor/TA won’t be directed to manually grade you work either.
-
If you would like to submit this version of your work (for automatic and/or manual grading), go to the Submitty website for this assignment and press the green “Grade My Repository” button.
Submitty will checkout the latest version of your code committed and pushed to the server, and will run any automated tests and automated grading on the assignment. When complete, you will see the results of this testing and grading on the website.
If you notice any problems with your work, you can modify the code on your local machine, commit those changes, push the commit to the server, and then press the green “Grade My Repository” button again.
-
TODO: We eventually plan to add a ‘hook’ to trigger repository grading in some situations (on each push to the server, and/or just before the assignment deadline). But currently this remains a manual step.
Other Useful GIT Commands
-
To search for a specific string within all the files in the repository:
git grep -ni 'SEARCH STRING'
Working with Instructor Provided Code
If your instructor distributes initial provided code and/or updates
this provided code, follow those instructions. If your instructor
chooses to distribute code via a provided branch, your interaction
will look like this:
-
Go to the top level of the directory, and check your current status:
git statusMake sure you are on the
mainbranch, and all of your changes have been committed. NOTE: Please refer to GIT documentation as needed. -
Grab all branches from the remote server:
git fetch -pYou can see what branches exist on your local machine and the server with:
git branch --allIf the instructor has made changes to the
providedbranch, you should see messages indicating that. -
You can review the commit messages on the
providedbranch:git log remotes/origin/provided(press spacebar to scroll, ‘q’ to quit, if the log is lengthy)
-
You can review the differences between your current branch (
main) and theprovidedbranch:git diff remotes/origin/provided(press spacebar to scroll, ‘q’ to quit if the diff is lengthy)
-
If you would like to merge the updates to the provided code with your current branch:
git merge remotes/origin/providedIf the changes don’t overlap with edits you have made (in different files, or in non-overlapping sections of the same files), the merge should complete automatically. If you have conflicts, you’ll need to handle that now. NOTE: Please refer to GIT documentation as needed.
Team Work with GIT
TODO: Let’s write some tips for working on teams… including using branches and handling merge conflicts.
See also: Instructor: Facilitating Student Submissions via GIT