Move uncommitted changes to a new branch
Safe: nothing is lost
Short answer
Run git stash, then git switch -c <new-branch>, then git stash pop. Your unfinished changes move to the new branch.
The commands, one by one
- 1
git stashPuts your unfinished edits aside and leaves the files clean.
- 2
git switch -c brunchCreates the branch
brunchand switches to it. - 3
git stash popBrings your edits back here and removes them from the stash.
For your own repository: Uncommitted changes actually follow you when you switch, so git switch -c brunch alone often works. The stash route also works when switching would refuse.