Back to Resources

Simple Git Tutorial

by Eddie Huang

Simple Git

The most popular version control system for managing programming code. Full git documentation

Repository Setup

Click here to create your repository (you only need do this once)

# Clone your repository into a new directory named cs225git
git clone https://github-dev.cs.illinois.edu/cs225-sp22/[YOUR NETID].git cs225git

# Add the release repository as a remote
git remote add release https://github-dev.cs.illinois.edu/cs225-sp22/_release.git

Assignment Setup

# Update your connection to the release repository
git fetch release

# Merge the lab_intro branch of the release repository into your repository
git merge release/lab_intro -m "Merging lab_intro from release repository"

Making a Checkpoint For Your Code

# Adding all tracked files to checkpoint
git add -u

# Making a local checkpoint with a meaningful description
git commit -m "Finally got the first test case to pass"

# Saving the checkpoint to the master branch of the origin remote
# This is also submitting your assignment for grading
git push origin master

Verify your Submission

We recommend you always verify your submission by visiting https://github-dev.cs.illinois.edu/ and viewing the files in your repository. Only the files that appear on the master branch of your github-dev repository will be graded.

Other Useful Commands

# Update your local repository with the remote repository
git pull

# Prints useful information about the present state of your
# local repository relative to the remote repository's state.
git status          

# Prints the commit history of the local repository
git log             

# When you want to redo the making of a new commit (all new edits are kept)
git reset           

# Permanently erases all un-committed changes
git reset --hard

# Permanently undo the latest commit
git reset --hard HEAD^

# Revert the changes specified by the fourth last commit in HEAD and create a new commit with the reverted changes.
git revert HEAD~3