10 Lesser-Known Git Commands That Will Level Up Your Workflow
Git Tips

10 Lesser-Known Git Commands That Will Level Up Your Workflow

If you’re a developer, you’re probably using Git every day. And chances are, most of the time you’re typing the same five or six commands: , , , , ... you know the drill.

But Git is a feature-rich version control system with many powerful commands that don’t get as much attention — even though they can save time, reduce errors, and boost productivity.

In this article, I’ll walk you through 10 Git commands that many developers overlook, and explain how each one can make your workflow smoother and smarter, with practical examples included.

1. git switch

🧭 A Modern, Clearer Alternative to for Switching Branches

Instead of using the old to switch branches, use . It’s cleaner and purpose-built for navigating between branches.

2. git restore

🧹 A Safe Way to Discard Changes in Your Working Directory

Use this command to discard local changes in your working directory before staging.

Example: You’ve edited , but want to undo it completely:\

Need to undo a staged file (before committing)?

Pro tip: Want to reset everything in the directory?

3. git log — oneline — graph — all

🌲 Visualize Your Git History as a Graph

This command shows a compact commit history with a visual branch structure. It’s an amazing way to understand how branches merge and diverge, especially when resolving conflicts or reviewing PR history.

4. git reflog

🔙 Recover Lost Commits and Branches

Think of as your Git history including the mistakes.

Example: You accidentally ran:

Now your latest 3 commits are gone… but not really! Run:

You’ll see something like:

Now restore a commit like this:

5. git cherry -v

🍒 See Which Commits Are Unique to Your Branch

This compares your current branch to another (like ) and shows commits that exist only in your current branch.

Example:

You’re on and want to check which commits haven’t been merged yet:

Output:

6. git shortlog -sn

👥 See a Summary of Contributions by Each Developer

Need to see who’s been most active in your repo?

Example output:

7. git diff — staged

🕵️ Double-Check What You’re About to Commit

This shows what you’ve added to the staging area (via ), and what will be committed.

8. git clean -fd

🧼 Clean Up Untracked Files and Directories

Deletes all untracked files and folders — useful when your repo feels “dirty” after testing or building.

🛑 Warning: This action is destructive — it cannot be undone!

9. git bisect

🔍 Find the Commit That Introduced a Bug

Git helps you do a binary search through your commit history to find the exact commit that broke your app.

Example:

You know the app was working in commit , but now it's broken.

Start bisecting:

Git checks out a middle commit. You test it and mark it:

Repeat until Git says:

Fix it, then end bisecting:

10. git worktree

🌳 Work on Multiple Branches at Once Without Cloning Again

This creates a separate working directory for a different branch — no need to stash or switch back and forth.

Example:

Now you have two folders, each with its own active branch. Perfect for:

  • Working on hotfixes without touching your current branch

  • Reviewing code without making local changes

  • Running two different branches side-by-side

To view or add a comment, sign in

Others also viewed

Explore topics