Sumit Saurabh's Avatar

Sumit Saurabh

@sumit.bsky.social

Full Stack Dev | πŸ₯‘ Developer Advocate πŸš€ | Public Speaker 🎀 | Talks about Javascript, React, Open Source and web dev

6,176 Followers  |  877 Following  |  331 Posts  |  Joined: 10.06.2023  |  1.9117

Latest posts by sumit.bsky.social on Bluesky

I hope you've found this thread helpful and learnt something new.

If you did:

βœ… Follow me @sumitsaurabh927 for more.
βœ… Like and comment down below
βœ… Repost the quote below:

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Join the Aviator - Developer Productivity Community Discord Server! Check out the Aviator - Developer Productivity Community community on Discord - hang out with 328 other members and enjoy free voice and text chat.

Join a community of early-age developers and level up:
discord.gg/pjTvDtE2

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

πŸ”Ÿ Final Takeaway: Use Git Stash Wisely

βœ”οΈ Great for quick, temporary saves
❌ Not a replacement for commits
πŸ’‘ When in doubt, create a branch instead

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

9️⃣ Bonus: Recovering a Dropped Stash 😱

Accidentally dropped a stash? You might still recover it:

Try: git fsck --lost-found and look for stash-like commits.

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

8️⃣ Managing & Cleaning Up Stashes

πŸ—‘ Clear all stashes: git stash clear
πŸ—‘ Delete a specific stash: git stash drop stash@{1}

Pro tip: If you use stashes often, clean them up regularly!

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

7️⃣ Better Alternatives to git stash

πŸš€ Use WIP commits: git commit -m "WIP"
πŸš€ Create a temporary branch
πŸš€ Use git worktree for parallel work

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

6️⃣ When You Shouldn’t Use git stash ❌

🚨 If your work is important (stashes aren’t safe long-term)
🚨 If you switch tasks often (easy to forget stashes)
🚨 If you need team visibility (stashes are local, not shared)

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

5️⃣ When You Should Use git stash βœ…

βœ”οΈ Switching branches temporarily
βœ”οΈ Need a clean working directory for testing
βœ”οΈ Quickly save work without committing

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

4️⃣ Applying a Specific Stash

If you have multiple stashes, apply a specific one using:

git stash apply stash@{2}

This applies the 3rd stash in your history (zero-based index).

04.03.2025 14:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

3️⃣ Keep Track of Stashes with Messages

By default, stashes are unnamed, which can get messy. Instead, use:

πŸ“ git stash push -m "WIP: Fixing login bug"
πŸ“œ View stash history: git stash list

04.03.2025 14:34 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

2️⃣ The Basics: Stashing and Applying

πŸ—„ Stash changes: git stash
♻️ Apply latest stash: git stash pop (removes it from stash history)
πŸ”„ Apply without removing: git stash apply

04.03.2025 14:34 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

1️⃣ What Is git stash?

πŸ”Ή Temporarily saves uncommitted changes
πŸ”Ή Cleans your working directory
πŸ”Ή Lets you switch branches without committing
πŸ”Ή Think of it as a clipboard for your code

04.03.2025 14:34 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

The Right Way to Use Git Stash (And When You Shouldn’t) πŸŽ©πŸš€

Ever needed to switch branches but didn’t want to commit half-done work?

'git stash' to the rescue!

But misusing it can cause headaches.

Here’s how to use it correctly (and when to avoid it) πŸ‘‡

04.03.2025 14:34 β€” πŸ‘ 1    πŸ” 1    πŸ’¬ 1    πŸ“Œ 0

I hope you've found this thread helpful and learnt something new.

If you did:

βœ… Follow me @sumitsaurabh927 for more.
βœ… Like and comment down below
βœ… Repost the quote below:

03.03.2025 16:05 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Preview
GitHub - aviator-co/av: A command line tool to manage stacked PRs with Aviator A command line tool to manage stacked PRs with Aviator - aviator-co/av

Don't forget to checkout our completely free tool 'av' cooked in the kitchens of @Aviator_co_ 🍜

It helps you create and manage stacked PRs completely free.

πŸ”—: github.com/aviator-co/av

03.03.2025 16:05 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

7️⃣ Bonus: Stacked PRs Work Best With Feature Flags 🚩

πŸ”Ή Ship incomplete features behind flags
πŸ”Ή Merge incrementally without affecting users
πŸ”Ή Reduce risk of breaking production

03.03.2025 16:05 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

6️⃣ Merge Strategy: Bottom-Up vs. Top-Down

πŸ”Ή Bottom-up: Merge base PR first, then the next
πŸ”Ή Top-down: Rebase from the base PR as you go

Tools like gh stack & av make this effortless!

03.03.2025 16:05 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

5️⃣ Example: Adding a Dark Mode Feature πŸŒ™

❌ One Big PR – Backend, API, UI, styles, settings all in one = πŸ”₯
βœ… Stacked PRs:
1️⃣ Backend: Store dark mode preference
2️⃣ API: Expose preference
3️⃣ UI: Toggle switch + styles

Much easier to review!

03.03.2025 16:05 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

4️⃣ Developers Benefit Too πŸš€

πŸ”Ή Less waiting for approvals
πŸ”Ή Merge work incrementally instead of all at once
πŸ”Ή Avoid rewriting code due to delayed feedback
πŸ”Ή Keep main branch stable while shipping fast

03.03.2025 16:05 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

3️⃣ Reviewers Love Stacked PRs ❀️

βœ… Faster reviews (small changes = quick feedback)
βœ… Focused discussions (each PR solves one problem)
βœ… Fewer merge conflicts (less code churn)
βœ… Easier debugging (pinpoint issues in smaller PRs)

03.03.2025 16:05 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

2️⃣ What Are Stacked PRs?

πŸ”Ή A sequence of smaller, dependent PRs
πŸ”Ή Each PR builds on the previous one
πŸ”Ή Easier to review since each PR focuses on a single step

Example:
βœ… PR 1: Refactor DB schema
βœ… PR 2: API changes
βœ… PR 3: Update UI

03.03.2025 16:05 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

1️⃣ Big PRs = Big Problems

❌ Hard to review
❌ Reviewers get lost in too many changes
❌ Endless back & forth slows progress
❌ Rubber-stamping leads to hidden bugs

Stacked PRs fix this πŸ‘‡

03.03.2025 16:05 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Why Stacked PRs Make Collaboration Easier πŸš€

PR reviews shouldn't feel like a battle.

Stacked PRs break big changes into smaller, reviewable pieces, making teamwork seamless.

Here’s why they supercharge collaboration πŸ‘‡

03.03.2025 16:05 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

I hope you've found this thread helpful and learnt something new.

If you did:

βœ… Follow me @sumitsaurabh927 for more.
βœ… Like and comment down below
βœ… Repost the quote below:

01.03.2025 13:58 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Preview
GitHub - aviator-co/av: A command line tool to manage stacked PRs with Aviator A command line tool to manage stacked PRs with Aviator - aviator-co/av

Don't forget to checkout our completely free tool 'av' cooked in the kitchens of @Aviator_co_ 🍜

It helps you create and manage stacked PRs completely free.

πŸ”—: github.com/aviator-co/av

01.03.2025 13:58 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

7️⃣ Stacked PRs + CI/CD = Speed & Safety

πŸš€ Deploy changes incrementally
πŸ”„ Rollback only the problematic PR
πŸ” CI tests each PR individually

This is how teams move fast without breaking things.

01.03.2025 13:58 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

6️⃣ Best Practices for Stacked PRs βœ…

βœ… Keep PRs small & logical
βœ… Merge regularly to avoid conflicts
βœ… Automate CI checks on each PR
βœ… Use a tool to manage the stack efficiently

01.03.2025 13:58 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

5️⃣ Stacked PRs Keep Your Main Branch Clean

πŸ”Ή Merge each PR independently
πŸ”Ή No more "feature branches lingering for weeks"
πŸ”Ή Keeps main always deployable

01.03.2025 13:58 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

4️⃣ Stacked PRs Reduce Context Switching

Reviewing small, focused PRs is faster than debugging a 5k-line monster.

Developers spend less time rebasing & more time shipping πŸš€

01.03.2025 13:58 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

3️⃣ How Stacked PRs Improve Velocity πŸš€

πŸ”Ή Parallel reviews β†’ Get feedback early
πŸ”Ή Fewer merge conflicts β†’ Merge quickly
πŸ”Ή Easier rollbacks β†’ Revert only the bad part
πŸ”Ή Better code quality β†’ Focused, reviewable diffs

01.03.2025 13:58 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

@sumit is following 1 prominent accounts