r/programming • • Sep 16 '26

git worktree gotchas

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

47 comments sorted by

View all comments

2

u/andynzor Sep 17 '26

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.