We use Git every day — but most of us stick to just
add
,commit
, andpush
.
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:
bashgit 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:
bashgit diff --staged
No more “Oops, I didn’t mean to commit that file!” moments.
3️⃣ Quickly Switch Back to the Last Branch
bashgit checkout -
or (modern way):
bashgit switch -
Great for jumping between two branches while fixing something quickly.
4️⃣ Save Work-in-Progress Without Committing
Got interrupted? Use stash:
bashgit 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:
bashgit pull --rebase
This keeps your commits in a straight line — much easier to read.
6️⃣ Avoid Typing Long Commands with Aliases
bashgit config --global alias.s "status -sb" git config --global alias.lg "log --oneline --graph --decorate"
Now:
bashgit s git lg
Your fingers will thank you. 🙌
7️⃣ View Who Changed a Line in a File
bashgit blame filename.js
Perfect for finding the commit (and person 😏) behind that mysterious code.
8️⃣ Ignore Files You Forgot to Ignore
bashgit 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.