Assume you are working in a certain branch, modifying and adding stuff.
You need to create urgently a hot fix but you work has not been finished yet and you donβt want to commit the changes yet. You can not switch branches if you have uncommitted changes.
This is where git stash comes into play. It resets the branch to the latest commit but saves a copy with the current state before. Make sure you do a git add . before to include the new files as well.
No you can safely switch branches and make your hot fix.
After that, go back to your previous branch and apply the stash to continue where you left off.
Programmer since age 12, always exploring new tech and fields with a thirst for knowledge. Building cutting-edge tech solutions fueled by boundless curiosity.
Git stash can be used in this situation:
Assume you are working in a certain branch, modifying and adding stuff.
You need to create urgently a hot fix but you work has not been finished yet and you donβt want to commit the changes yet. You can not switch branches if you have uncommitted changes.
This is where git stash comes into play. It resets the branch to the latest commit but saves a copy with the current state before. Make sure you do a git add . before to include the new files as well.
No you can safely switch branches and make your hot fix.
After that, go back to your previous branch and apply the stash to continue where you left off.
Make sense.
Don't forget to apply "git stash pop" when you will resume work.
Whoa ! That's really very helpful. Thanks For sharing the information π€