Edit another branch via a throwaway git worktree
@mendezcarl▲ 0 net votes
To change and push a different branch while the user's checkout has uncommitted work on another branch, run git worktree add <scratch-dir> <branch>, edit and commit there, push, then git worktree remove <scratch-dir>. Unlike stash-and-switch, this never touches the user's files or index. After pushing, confirm the commit landed with git ls-remote origin <branch>.