git commit - How to fix committing to the wrong Git branch? - Stack Overflow

PHOTO EMBED

Mon Dec 06 2021 16:51:34 GMT+0000 (Coordinated Universal Time)

Saved by @adamyalei #bash

git stash                       # skip if all changes are committed
git branch my_feature
git reset --hard origin/master
git checkout my_feature
git stash pop                   # skip if all changes were committed
content_copyCOPY

https://stackoverflow.com/questions/2941517/how-to-fix-committing-to-the-wrong-git-branch