Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

Git Lab Exercise & Assignment: Git Stash: Part – 11

Often, when youโ€™ve been working on part of your project, things are in a messy state and you want to switch branches for a bit to work on something else. The problem is, you donโ€™t want to do a commit of half-done work just so you can get back to this point later. The answer to this issue is the git stash command.

You can also put it somthing like this, Your code is in progress and suddenly a customer escalation comes. Because of this, you have to keep aside your new feature work for a few hours. You cannot commit your partial code and also cannot throw away your changes. So you need some temporary space, where you can store your partial changes and later on commit it.

Stashing takes the dirty state of your working directory โ€“ that is, your modified tracked files and staged changes โ€“ and saves it on a stack of unfinished changes that you can reapply at any time.



# Modify | Add  Some files in Git working directory
$ git status
Now you want to switch branches, but you donโ€™t want to commit what youโ€™ve been working on yet; so youโ€™ll stash the changes. To push a new stash onto your stack, run git stash or git stash save:


$ git stash
Your working directory is clean:


$ git status
At this point, you can easily switch branches and do work elsewhere; your changes are stored on your stack. To see which stashes youโ€™ve stored, you can use git stash list:


$ git stash list
stash@{0}: WIP on master: 049d078 added the index file
stash@{1}: WIP on master: c264051 Revert "added file_size"
stash@{2}: WIP on master: 21d80a5 added number to log
If you want to apply one of the older stashes, you can specify it by naming it, like this: git stash apply stash@{2}.


$git stash apply stash@{2}
If you donโ€™t specify a stash, Git assumes the most recent stash and tries to apply it:


$ git stash applyCode language: PHP (php)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Top 10 Digital Signature Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, digital transformation has reshaped the way businesses manage documents, sign agreements, and engage with clients. Digital signatures have become an essential component of this…

Read More

Top 10 Graphics Design Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, graphics design tools are more essential than ever for businesses, content creators, designers, and marketers across industries. From creating brand identities and advertising materials…

Read More

Top 10 Presentation Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, creating engaging and impactful presentations is more than just slides with bullet pointsโ€”itโ€™s about telling a story, conveying ideas visually, and keeping your audience…

Read More

How to Optimize Your headless CMS for Multilingual Websites

A multilingual site enables a company to internationalize itself to different audiences for better engagement and ultimately, international brand awareness. However, without the proper considerations with the…

Read More

Top 10 AI SEO Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI SEO tools have become indispensable for digital marketers, businesses, and content creators aiming to dominate search engine rankings. These tools leverage artificial intelligence…

Read More

Top 10 Product Lifecycle Management (PLM) Tools in 2026: Features, Pros, Cons & Comparison

Introduction Product Lifecycle Management (PLM) is a strategic approach to managing a productโ€™s journey from conception through design, manufacturing, and end-of-life. In 2026, PLM software has evolved…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Jason Mitchell
Jason Mitchell
1 month ago

Good hands-on explanation of git stash and how it helps save uncommitted work temporarily. One practical thing worth adding is that in real team workflows, stashes can quickly become a โ€œhidden state problemโ€ if overusedโ€”people forget what they stored or apply it on the wrong branch later. In CI/CD or collaborative environments, itโ€™s usually safer to prefer short-lived feature branches over long stash chains, since stashes donโ€™t get reviewed, tracked, or protected like commits do.

1
0
Would love your thoughts, please comment.x
()
x