Are git stash
and git stash pop
a good solution for this problem?
I was working on branch B, but something happened accidentally and unbeknownst to me, put me back into an older branch, branch A, where I kept working blindly on various tasks.
Git wants me to commit my new work to branch A, before I can switch over to branch B, but I can't (shouldn't) do that.
Is it safe (meaning will I not lose all my work, but be able to put it over into its correct branch) to, while on branch A (the wrong branch), do git stash
, then switch to branch B (correct branch) and do git stash pop
? Will I encounter any disasters by doing that? Will all of my work be instantly in the correct branch and I can commit and push as normal?
I am nodding off and unsure of how not to blow up my Git project.
This post answers my question, I think, but is it up to date? Also, from that post:
To also stash currently untracked (newly added) files, add the argument
-u
What is the difference between uncommitted and untracked/newly added files? Aren't uncommitted files more or less "newly added"?