Basic Git and Terminal Commands

Terminal Basics

Moving around your local machine.

CommandDescription
lsList: See everything inside your current folder.
cdChange Directory: Go to your main home folder.
cd ..Go Back: Move up one level (to the "parent" folder).
cd desktopMove into your Desktop folder.
cd "folder name"Jump into a specific folder.
mkdir "name"Make Directory: Create a brand new folder.
ni name.extNew Item: Create a new file (e.g., index.html).

Starting & Tracking

Getting your project ready for Git.

CommandDescription
git initStart a new Git repo in your current folder.
git clone <url>Grab a copy of a project from GitHub or another online source.
git statusCheck what’s changed and what is currently being tracked.
git logSee your full history of "saves" (commits).
git log --onelineA much cleaner, one-line view of your history.

Staging & Committing

Preparing your changes and saving them to your local history.

CommandDescription
git add .Stage everything in the current folder.
git add -AStage 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 id2See exactly what lines changed between two different saves.

Deleting & Undoing

When you need to fix a mistake or roll back the clock.

CommandDescription
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 resetUnstage your files (moves them back to "untracked").
git reset --hardNuclear 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.

CommandDescription
git branchSee 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.

CommandDescription
git push origin mainSend your local saves up to the online repo (GitHub).
git stashQuickly hide your "in-progress" work so you can switch tasks.
git stash popBring 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.

Author:
Rosh Khan
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2026 The Information Lab