Skip to main content

Command Palette

Search for a command to run...

Day 31: Git Stash | 100 Days of DevOps

Updated
2 min read
R
I’m currently working in DevOps and documenting my learning journey along the way. From CI/CD pipelines to cloud and containers, I’m exploring how modern systems are built and deployed. This blog is where I share what I learn, break down concepts in simple terms, and track my progress. Learning one concept at a time, and trying to apply it practically.

Content:

Today I worked on restoring stashed changes in a Git repository and pushing them to the remote repository. The task involved identifying a specific stash entry, applying it, and then committing and pushing those changes.


🔹 What I Learned

  • How to view stashed changes using git stash list
  • Difference between git stash apply and git stash pop
  • How to restore a specific stash using its identifier

Steps I Followed

1. Connected to Storage Server

ssh natasha@ststor01

2. Switched to Root User

sudo su

3. Navigated to the Repository

cd /usr/src/kodekloudrepos/apps

4. Checked Available Stashes

git stash list

Observed multiple stash entries:

stash@{0}
stash@{1}

5. Applied the Required Stash

git stash apply stash@{1}

This restored the changes (a new file welcome.txt) and staged them automatically.


6. Verified Changes

git status

Confirmed that welcome.txt was ready to be committed.


7. Committed the Changes

git commit -m "Restored changes from stash@{1}"

8. Pushed Changes to Remote Repository

git push origin master

9. Verified Push

The push was successful and changes were reflected in the remote repository.


🔹 My Understanding

This task helped me understand how Git stash works as a temporary storage for uncommitted changes. I learned how to retrieve specific stashed work without disturbing others and properly integrate it back into the repository workflow.


🔹 What I Found Interesting

I found it interesting that Git allows multiple stashes and lets us restore any specific one using an identifier. It’s a very useful feature when working on multiple tasks simultaneously, as it helps keep work organized without committing incomplete changes.


📌 Full notes: GitHub link