Erik Fredericks, frederer@gvsu.edu Fall 2025
Based on material provided by Erin Carrier, Austin Ferguson, and Katherine Bowers
Git repositories contain:
Git repositories are stored:
Git is distributed!
Commit objects contain:
If two commits are exactly the same, the identifier will be the same.
HEAD
index
SHA-1
git init
git add
git rm
-rf
git mv
git commit
git status
git diff
git log
git show <sha1>
NOTE
git checkout <sha1>
DETACHED HEAD
git checkout main
I added (staged) a file but didn't mean to
Options:
git restore --staged filename
git reset filename
I've really screwed up a file, I just want to get rid of all my changes
git restore filename
git checkout filename
git checkout -- filename
However, if already staged (meaning you did git add):
git restore --staged --worktree filename
Now you've done it - you messed up your local working directory! How do I go back
git reset --hard
git restore --staged --worktree .
Get yourself a visual diff editor
diff
Main file manipulation git commands:
git add file
git mv source dest
git rm file
git commit -m "message"
Status commands
git diff file
what is missing when working local, why?
init new git repo add file commit update file commit update file stage revert