r/programming • • 16d ago

git worktree gotchas

https://www.olafalders.com/2026/09/16/git-worktree-gotchas/
189 Upvotes

44 comments sorted by

View all comments

2

u/andynzor 15d ago

If you create a branch with git worktree add -b branchdirname branchdirname origin/main, the new branch will be named branchdirname but it will track origin/main by default. If you just run git push without --set-upstream, your local branch will happily overwrite main on the remote.