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