Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Alright, I want to move unstaged edits to a new branch. If the branch doesn't exist, I want to use checkout, but if it does exist I need to stash, checkout and then stash pop

Use `git switch` instead. `git checkout` is known to be overloaded to do too many things.

If it's a new branch, `git switch --create <branch>`

If it's an existing branch and the changes would conflict, `git switch --merge <branch>`



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: