Archived Content

This website is an archive of the Spring 2023 semester of CS 225.
Click here to view the current semester.
Back to Resources

Simple Git Tutorial

by Eddie Huang

Simple Git

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

Assignment Setup

# Update your connection to the release repository
git fetch release

You can merge the assignments as they are released into your personal repo with

git pull --no-edit --no-rebase release main
git push

if you are using multiple machines you may need to use the following to allow them to work correcly.

git pull --no-edit --no-rebase release main --allow-unrelated-histories
git push

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 main branch of the origin remote
git push origin main

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