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 AI Fraud Detection Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, the global financial landscape faces unprecedented challenges from sophisticated fraud tactics, including deepfakes, synthetic identity fraud, and automated bot attacks. AI fraud detection tools…

Read More

Toptal Alternatives: 6 Best Platforms to Hire Remote Tech Talent

Are you looking for remote developers, designers, or project managers, without Toptalโ€™s price tags and wait times? Youโ€™re not alone. Weโ€™ve been through the search ourselves, and…

Read More

List of Best Compliance Automation Tools

What Are Compliance Automation Tools Used For? Compliance automation tools are software platforms designed to help organizations meet industry, regulatory, and security standardsโ€”with less manual effort, fewer…

Read More

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

Introduction In 2026, AI compliance audit tools are indispensable for organizations navigating the complex regulatory landscape driven by rapid AI adoption. With 78% of companies integrating AI…

Read More

Top 10 HIPAA Compliance Tools in 2026: Features, Pros, Cons & Comparison

Introduction HIPAA (Health Insurance Portability and Accountability Act) compliance is essential for healthcare organizations to ensure the security and privacy of patient data. With cyber threats becoming…

Read More

What is a GitHub App?

๐Ÿง  What is a GitHub App? A GitHub App is a first-class actor in the GitHub ecosystem. Unlike OAuth apps which act on behalf of a user,…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Jason Mitchell
Jason Mitchell
4 months 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