How to move uncommitted code to a different branch in Git?
Published October 18, 2020
Many times I had this problem where I start implementing a feature in my
main branch only to realize that this is not the appropriate branch to implement it 🤯. The following tip will quickly help you to recover from this situation 🌟.
To move uncommitted code to a different branch, you can use the
command to temporarily store the code to Git Stash.
Then you need to change to the branch you need to move the code using this command,
git checkout name_of_branch
After changing to the branch you can use,
git stash pop
command to get the code from the stash.
Now, you will get the uncommitted code written to files in the new branch.