Terminal Basics
Moving around your local machine.
| Command | Description |
ls | List: See everything inside your current folder. |
cd | Change Directory: Go to your main home folder. |
cd .. | Go Back: Move up one level (to the "parent" folder). |
cd desktop | Move into your Desktop folder. |
cd "folder name" | Jump into a specific folder. |
mkdir "name" | Make Directory: Create a brand new folder. |
ni name.ext | New Item: Create a new file (e.g., index.html). |
Starting & Tracking
Getting your project ready for Git.
| Command | Description |
git init | Start a new Git repo in your current folder. |
git clone <url> | Grab a copy of a project from GitHub or another online source. |
git status | Check what’s changed and what is currently being tracked. |
git log | See your full history of "saves" (commits). |
git log --oneline | A much cleaner, one-line view of your history. |
Staging & Committing
Preparing your changes and saving them to your local history.
| Command | Description |
git add . | Stage everything in the current folder. |
git add -A | Stage everything in the entire project. |
git add "file" | Stage one specific file or folder. |
git commit -m "msg" | Save your staged changes with a quick note. |
git diff id1 id2 | See exactly what lines changed between two different saves. |
Deleting & Undoing
When you need to fix a mistake or roll back the clock.
| Command | Description |
git rm "file" | Delete a file and tell Git about it immediately. |
git rm --cached "file" | Stop tracking a file but keep it on your computer. |
git reset | Unstage your files (moves them back to "untracked"). |
git reset --hard | Nuclear option: Wipe changes and restore deleted files. |
git reset HEAD~ | Undo your very last commit but keep the work you did. |
git restore . | Wipe your local changes and go back to the last save. |
git revert "id" | Undo a specific old save without erasing your history. |
Branching & Merging
Working on new features without breaking the "Main" code.
| Command | Description |
git branch | See a list of all your branches. |
git branch "name" | Create a new branch (but stay where you are). |
git switch "name" | Jump over to a different branch. |
git merge "name" -m "" | Combine a branch's work into your current one. |
git checkout "id" | "Time travel" back to see what the code looked like then. |
Remote & Stashing
Handling the cloud and multi-tasking.
| Command | Description |
git push origin main | Send your local saves up to the online repo (GitHub). |
git stash | Quickly hide your "in-progress" work so you can switch tasks. |
git stash pop | Bring your hidden "in-progress" work back. |
Tip: If you’re ever stuck in a screen you can’t get out of (like the Git Log), just hit q on your keyboard to quit back to the normal prompt.
