Version Control
Git Daily Workflow Cheatsheet
Check Current State
Show changed files
Use this before and after edits to see what is modified, staged, or untracked.
git statusShow the current branch
Use this to confirm you are working on the expected branch.
git branch --show-currentShow recent commits
Use this to quickly inspect the latest local history.
git log --oneline -5Stage And Commit
Stage all changed files
Use this when you want to include every current file change in the next commit.
git add .Create a commit
Use this to save staged changes with a clear message.
git commit -m "Describe the change"Push Changes
Push the current branch
Use this after committing when the branch already tracks a remote branch.
git pushPush a new branch for the first time
Use this when the branch does not yet exist on GitHub.
git push -u origin branch-nameBranching
Create and switch to a new branch
Use this before starting isolated feature work.
git switch -c feature/my-changeSwitch back to main
Use this before syncing or starting a new branch from main.
git switch mainPull latest main
Use this to sync your local main branch with GitHub.
git pullReview Changes
Show unstaged changes
Use this to review edits before staging.
git diffShow a summary of changed files
Use this for a compact view of the diff size.
git diff --statShow staged changes
Use this to review exactly what will go into the next commit.
git diff --cachedRecovery
Unstage a file
Use this when you staged a file but do not want it in the next commit.
git restore --staged path/to/fileKeep In Mind
- Commit small, meaningful changes.
- Pull before starting new work.
- Read diffs before committing.
- Avoid force pushing unless you know exactly why.