When would you use git stash instead of committing to a new branch, and what are the trade-offs?
- `git stash` saves dirty state without a commit; branch creates explicit history
- Stash is temporary and stack-based; branches are shareable and reviewable
- Use stash for quick context switches; branch for collaborative work
- 💡Mention `git stash list` / `stash pop` / `stash apply`.
- ⚠️Misusing `git stash` for significant, long-term work that should inherently be tracked on a dedicated branch.
- ⚠️Forgetting to apply or drop stashed changes, leading to a cluttered stash list and potentially lost work.
- ⚠️Not understanding that `git stash` by default does not save untracked or ignored files, requiring the `-u` or `--include-untracked` flag.
- ⚠️Committing incomplete or broken 'WIP' (Work In Progress) changes directly to a branch instead of utilizing `git stash` for a cleaner history.
- ⚠️Expecting stashed changes to be automatically synchronized or visible to collaborators, as stashes are purely local to your repository.
- ❓How do you stash untracked files?
- ❓How do you name a stash?
Ready to prove your AWS DevOps knowledge?
Practice with free DevOps Engineer Professional (DOP-C02) exam questions. Instant answers and detailed explanations — no account required.
Start free practice quizQuestions that share similar topics with this one
Deepen your knowledge with these related blog posts
Monorepo vs Polyrepo: Choosing the Right Repository Strategy for Your Microservices
A comprehensive guide to choosing between monorepo and polyrepo strategies when decomposing monoliths into microservices. Learn the trade-offs, implementation patterns, and real-world considerations that matter in production.
GitHub Self-Hosted Runners on AWS: Pull vs Push for On-Demand Scaling
Cut your CI costs by running GitHub Actions on AWS only when you need them. Compare pull-based (polling) and push-based (event-driven) architectures for spinning up on-demand self-hosted runners.
From Terraform to GitOps: A Practical Migration Roadmap
A step-by-step guide to migrating from traditional Terraform workflows to GitOps, including migration patterns, common pitfalls, and practical diagrams to guide your journey.