Is there any way to undo all un-pushed commits (I made 3 commits to the wrong branch without pushing) without losing the changes?
You can use git reset
to get back to previous commits.
Make sure to use the --mixed option, so it keeps your changes but removes the commits:
git reset --mixed HEAD~3