Introduction to Git
George Boorman
Curriculum Manager, DataCamp
ls, cdgit initgit add ., git commit -mHow Git stores data
git log
3--since--untilgit show c27fa856

| Command | Function |
|---|---|
git diff report.md |
Show changes between unstaged file and the latest commit |
git diff --staged report.md |
Show changes between staged file and the latest commit |
git diff 35f4b4d 186398f |
Show changes between two commits using commit hashes |
git diff HEAD~1 HEAD~2 |
Show changes between two commits using HEAD syntax |
| Command | Result |
|---|---|
git revert HEAD |
Revert all files from a given commit |
git revert HEAD --no-edit |
Revert without opening a text editor |
git revert HEAD -n |
Revert without making a new commit |
git checkout HEAD~1 -- report.md |
Revert a single file from the previous commit |
git restore --staged report.md |
Remove a single file from the staging area |
git restore --staged |
Remove all files from the staging area |
Introduction to Git