🚀 7 Git Tricks You Probably Didn't Know Existed
Shahrkh Sidd

Shahrkh Sidd @shani

About: Express your creativity with own your work hard

Joined:
Jul 28, 2025

🚀 7 Git Tricks You Probably Didn't Know Existed

Publish Date: Jul 28
0 0

We all use git daily, but it has a ton of powerful (and lesser-known) features that can make your life easier. Here are some Git tricks that go beyond git status and git push.

  1. Undo Your Last Commit (But Keep Changes)

git reset --soft HEAD~1

This undoes your last commit but keeps your changes staged. Super handy when you realize your commit message was wrong or you forgot to include a file.

  1. Remove a File from History (Without Nuking Your Repo)

git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch SECRET_FILE" \
--prune-empty --tag-name-filter cat -- --all

Oops! Did you commit an API key? This will remove the file from all commits.
(Use with caution — history rewrite ahead!)

  • Remove a File from Git History

    📘 Removing Sensitive Data from Git History

  1. See Who Changed a Specific Line

git blame FILE

Find out who changed which line of code and when. Useful for tracking down bugs or understanding legacy logic.

  • Git Blame

    📘 Git Blame Documentation

  1. Stash Only Certain Files

git stash push -m "my partial stash" myfile.js

No need to stash everything. This command lets you stash just one or a few files.

  1. Show Changes in a File You Staged

git diff --cached

Check what's going to be committed — super helpful before running git commit.

  1. Remove Local Branches That Are Already Merged

git branch --merged | grep -v '*' | xargs git branch -d

Clean up your local repo by deleting all fully merged branches.

  1. See Your Commit History Like a Tree

git log --oneline --graph --all

Visualize your commit history across branches. Great for understanding project flow.

💬 Got Any Favorites?

Which of these did you not know? Or do you have a secret Git trick of your own?
Drop it below — let’s learn from each other! 🙌

Comments 0 total

    Add comment