1. 9
    Practical Git: Save uncommitted changes with git stash
    2m 51s

Practical Git: Save uncommitted changes with git stash

Trevor Miller
InstructorTrevor Miller

Share this video with your friends

Send Tweet

Sometimes when we are working we need a way to pause and switch gears to deal with something more critical; often when this happens we aren't ready to create a git commit; instead, we can use git stash to save our uncommitted changes locally, switch branches and fix the critical issue, switch back to our incomplete feature, and finally run git stash apply to get our unfinished changes back into our branch without affecting the rest of the codebase. In this lesson, we show a real world example of doing this with a critical bug.

Lucky
Lucky
~ 4 years ago

If we are using a new branch for a feature then can't we simply checkout to the master branch and then create a new branch for the hotfix? Does the newly created branch copy all files from all branches or does it only resemble the branch that we were on before creating the new branch? And what if we have already committed changes in the new feature branch, will the git stash still be helpful?