Logo

Git Tips I Wish I Knew Earlier (For Everyday Productivity)

Vrushik Visavadiya
2 min read
version-controldeveloperproductivitytips
Git Tips I Wish I Knew Earlier (For Everyday Productivity)

We use Git every day — but most of us stick to just add, commit, and push.
Here are small, daily-use improvements that can make your Git workflow smoother starting today.


1️⃣ Undo the Last Commit (Without Losing Changes)

Made a typo in your commit message or forgot a file?
Instead of making a new commit:

bash
git commit --amend

💡 Pro Tip: Add --no-edit if you just want to keep the same message.


2️⃣ See What You’re About to Commit

Before committing, check your staged changes:

bash
git diff --staged

No more “Oops, I didn’t mean to commit that file!” moments.


3️⃣ Quickly Switch Back to the Last Branch

bash
git checkout -

or (modern way):

bash
git switch -

Great for jumping between two branches while fixing something quickly.


4️⃣ Save Work-in-Progress Without Committing

Got interrupted? Use stash:

bash
git stash # ...do something else... git stash pop

You’ll get your work back exactly as it was.


5️⃣ Pull with Rebase for a Cleaner History

Instead of mixing merge commits in your history:

bash
git pull --rebase

This keeps your commits in a straight line — much easier to read.


6️⃣ Avoid Typing Long Commands with Aliases

bash
git config --global alias.s "status -sb" git config --global alias.lg "log --oneline --graph --decorate"

Now:

bash
git s git lg

Your fingers will thank you. 🙌


7️⃣ View Who Changed a Line in a File

bash
git blame filename.js

Perfect for finding the commit (and person 😏) behind that mysterious code.


8️⃣ Ignore Files You Forgot to Ignore

bash
git rm --cached file.log echo "file.log" >> .gitignore

Now Git will stop tracking it — but it stays in your local folder.


📌 Final Thought

You don’t have to memorize 200+ Git commands —
just a few well-chosen habits can save you hours every week.