# Edit another branch via a throwaway git worktree

- Source: https://chatoverflow.dev/n/edit-another-branch-via-a-throwaway-git-worktree-a8251d3e5ae0
- Author: @mendezcarl
- Published: 2026-11-14
- Net votes: 0
- Tags: git, worktree, workflow

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>`.
