
Whether you're new to Git or want to keep your workflow sharp, here’s a handy list of commands that cover the most common — and a few life-saving — actions.
Clone the repo
git clone <repository-url>
🔍 See What's Going On
git status
Shows what's changed, what's staged, and what's untracked.
git log --oneline
View commit history (detailed or summarized).
➕ Stage & Commit Changes
git add <file> # Stage a single file
git add . # Stage everything
git commit -m "Your message here" Creates a commit with your staged changes.
💡 Git Tip: Think of Git as a three-step process:
1️⃣ Working Directory – where you make edits
2️⃣ Staging Area – where you select what to commit
3️⃣ Repository – where your project history livesStaging gives you control over what gets committed, so you can group related changes together before saving them permanently.
🔄 Stash Changes
git stash -m "WIP: login bug" # Save changes with a label
git stash list # View stashes
git stash apply [stash@{id}] # Reapply a specific stash
💡 Git Tip: Need to switch tasks but don’t want to commit your work yet?
Usegit stashto save your changes temporarily and return to a clean working state.
Later, usegit stash applyto get your work back.🛠️ Pro Tip: Use
git stash listto see all stashes, andgit stash dropto delete one you no longer need
🌿 Branching
git branch # List branches
git branch feature-xyz # Create a new branch
git checkout feature-xyz # Switch to it
git checkout -b feature-xyz # Create and switch to a new branch in one line
git switch feature-xyz # Newer switch syntax
⬇️⬆️ Sync with Remote
git pull # Pull latest changes
git push # Push local commits
# Sets the upstream tracking branch when pushing for the first time
git push -u origin [branch-name]
# Force-push your local branch — use with caution! Ideal after a rebase:
git push --force
🔧 Undoing Mistakes
git restore <file> # Discard local changes
git restore --staged <file> # Unstage a file
🧨 Life-Saving Commands
Pull the latest from main and rebase your current branch in one single step:
git fetch && git rebase origin/main
💡 Git Tip: Keep your branch up-to-date and avoid merge commits by rebasing onto the latest
main. Perfect for clean history before a PR.
Remove commits but keep the changes:
💡 Need to rewrite history?
--softlets you uncommit changes but keeps them staged so you can tweak and recommit.
git reset [commit-hash] --soft
Pull a file from another branch to modify it locally:
💡 Want just one file from another branch? This command pulls it into your current branch without switching context.
git checkout other-branch -- path/to/file
About the author
- I'm a software engineer with over 15 years of experience. While my background is primarily in backend engineering, my work today spans cloud infrastructure, AI integrations, and the systems that support modern software applications. I started this blog to share what I’ve learned in a simplified, approachable way — and to add value for fellow developers. Though I’m an introvert, I’ve chosen to put myself out there to encourage more women to explore and thrive in tech. I believe that by sharing what we know, we learn twice as much — that’s precisely why I’m here.
Comments
Join the discussionNo comments yet. Be the first to comment.




