GitHubApr 19, 2025Version Control

GIT Commands

A practical Git guide with the commands I use most often, explained in a way that is quick to scan and easy to remember.

A simple Git routine keeps your history clean and makes it easier to collaborate, review changes, and recover work when something goes wrong.

Memory trick: status tells you what changed, add prepares it, commit saves it, push shares it.

Core commands

`git status`

Checks what changed in the working directory and what is ready to be staged.

git status

`git add`

Moves files into the staging area so they can be included in the next commit.

git add .

`git commit`

Saves your staged changes as one clear snapshot with a message.

git commit -m "Describe the change"

`git push`

Sends your local commits to GitHub so the remote repo stays updated.

git push origin main

`git pull`

Downloads the latest changes from GitHub and merges them into your local branch.

git pull origin main

`git branch`

Shows your branches or creates one for isolated work.

git branch git branch feature-name

`git log`

Displays the commit history when you want to review what was changed.

git log --oneline

`git diff`

Highlights the actual line-by-line edits before you commit them.

git diff

Typical workflow

1. Check the state of your repo Confirm what changed before you do anything else. git status
2. Review the diff if needed Look at the exact edits so you know what will be committed. git diff
3. Stage only the files you want Use add to prepare a clean commit. git add .
4. Commit with a message that explains the change Keep the message short, specific, and readable later. git commit -m "Update dashboard layout"
5. Push to GitHub Share the work so your remote repo stays in sync. git push origin main

Tips for interviews

Say the purpose, not just the command: interviewers like when you explain why you used a command, not only its syntax.
TagsGitHubGitCommandsVersion Control