Loading lessons...
Snapshotting Commands
Snapshotting Commands
These commands handle staging, saving, and moving files in your repository.
git add
git add file.txt
git add .
Stages changes into the staging area.
git status
git status
git status -s
Shows the state of the working directory and staging area.
git diff
git diff
git diff --staged
Shows changes between versions. --staged previews the next commit.
git commit
git commit -m "Message"
git commit -am "Message"
Saves a snapshot of your staged changes.
git restore
git restore file.txt
git restore --staged file.txt
Discards working changes, or unstages files. The modern replacement for checkout file restores.
git reset
git reset --soft HEAD~1
git reset --hard abc123
Moves the branch pointer backward.
git rm and git mv
git rm file.txt
git mv old.txt new.txt
Remove a file from the repo, or move/rename it.
TL;DR
- add and commit save snapshots.
- status and diff show what is going on.
- restore and reset undo or unstage changes.
- rm and mv remove and rename tracked files.