Lädt...

🔧 [Git] How to Temporarily Save Changes with `git stash` While Switching Branches


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

1st March 2025

While working on a team project, there might be times when you're in the middle of writing code on your feat branch but need to switch to the dev branch to check something. In this case, you can use the git stash command to temporarily save your work without committing unfinished changes.

Steps

  1. Save your current changes:
   git stash push -m "Description of your work in progress"
  1. Switch to the dev branch:
   git switch dev
  1. After checking what you need on dev, switch back to your feat branch:
   git switch feat
  1. Restore your stashed changes:
   git stash pop

The git stash pop command applies the latest stash and automatically removes it from the stash list. If you want to apply the stash without deleting it, use:

git stash apply

What If You Have Multiple Stashes?

If you've stashed your work multiple times, you can see the list of saved stashes:

git stash list

Example output:

stash@{0}: On branch_name: Work in progress 2
stash@{1}: On branch_name: Work in progress 1

To apply a specific stash, use:

git stash pop stash@{0}

I haven't used multiple stashes much yet, but if I do, I'll come back and explain the process in more detail.

...

🔧 [Git] How to Temporarily Save Changes with `git stash` While Switching Branches


📈 97.89 Punkte
🔧 Programmierung

🔧 How to temporarily save your uncommitted changes using Git Stash?


📈 54.89 Punkte
🔧 Programmierung

🔧 How to temporarily save your uncommitted changes using Git Stash?


📈 54.89 Punkte
🔧 Programmierung

🔧 Mastering Git Stash: A Guide to Temporarily Shelving Changes in Git


📈 53.54 Punkte
🔧 Programmierung

🔧 Mastering Git Stash: A Guide to Temporarily Shelving Changes in Git


📈 53.54 Punkte
🔧 Programmierung

🐧 How to Git stash Pop Specific Stash


📈 41.27 Punkte
🐧 Linux Tipps

🔧 How to Clean Up Git Branches: Scripts to Delete Old, Inactive, and Unused Branches


📈 39.98 Punkte
🔧 Programmierung

🔧 Difference between main branches and master branches in #git and #github


📈 39.98 Punkte
🔧 Programmierung

🔧 A Complete Guide to Temporarily Saving Your Work With Git Stash


📈 39.03 Punkte
🔧 Programmierung

🔧 DAY 5 Git rebase, Git stash, Git cherry-pick.


📈 35.38 Punkte
🔧 Programmierung

🔧 Git Rebase and Git stash and Git pop -day 4


📈 35.38 Punkte
🔧 Programmierung

🔧 Restaurando e Alternando Branches com Git: Domine os Comandos git restore e git switch


📈 34.73 Punkte
🔧 Programmierung

🔧 git switch and git checkout – How to switch branches in git


📈 34.73 Punkte
🔧 Programmierung

🔧 💡 How to Pull Updates for All Git Branches Without Switching Manually


📈 34.42 Punkte
🔧 Programmierung

🔧 Automatically Update the Local Branch with the Remote Version When Switching Branches in Git


📈 34.42 Punkte
🔧 Programmierung

🔧 Mastering Git: Undoing Changes with Reset, Revert, Stash, and More


📈 32.2 Punkte
🔧 Programmierung

🔧 Mastering Git Stash: A Handy Tool for Managing Uncommitted Changes


📈 32.2 Punkte
🔧 Programmierung

🔧 From Changes to Safe Keeping: Git Stash


📈 32.2 Punkte
🔧 Programmierung

🔧 Stash changes in a git repository with VS Code


📈 32.2 Punkte
🔧 Programmierung

🔧 Guide to Git Stash: Keeping Your Workspace Clean While Coding


📈 32.17 Punkte
🔧 Programmierung

🔧 How to Temporarily Store Changes in Git


📈 29.95 Punkte
🔧 Programmierung

🔧 How to tell Git to temporarily ignore changes to a file


📈 29.95 Punkte
🔧 Programmierung

🐧 git-stash Command in Git | Explained


📈 29.48 Punkte
🐧 Linux Tipps

🐧 Git Stash: Der nützliche Zwischenspeicher in Git


📈 29.48 Punkte
🐧 Server

🔧 Mastering Git Branching and Merging: A Complete Guide to Git Branches, Merge, Rebase, and More


📈 28.84 Punkte
🔧 Programmierung

🔧 Git Tags and Git Branches


📈 28.84 Punkte
🔧 Programmierung

🐧 temporarily switching back to just windows


📈 26.92 Punkte
🐧 Linux Tipps

🪟 Stash this Portable Car Jump Starter in your glove box while it's under $50


📈 26.27 Punkte
🪟 Windows Tipps

🔧 Temporarily rolling back SameSite Cookie Changes


📈 24.06 Punkte
🔧 Programmierung

🍏 Using Smart Speakers While Temporarily Blind


📈 24.03 Punkte
🍏 iOS / Mac OS

🔧 DAY4-GIT BRANCH,STASH.


📈 23.59 Punkte
🔧 Programmierung

🔧 Git Stash Magic: Navigating Code Emergencies and Context Switches with Ease


📈 23.59 Punkte
🔧 Programmierung

🔧 Pick Files from a List for Git Add and Stash Directly in Your Terminal


📈 23.59 Punkte
🔧 Programmierung

🔧 Git Stash - A Quick Primer


📈 23.59 Punkte
🔧 Programmierung

matomo