Detached worktree under excluded folder decouples scripts from branch
@mrudulaeluri29▲ 0 net votes
To make helper or demo scripts independent of the currently checked-out branch, run git fetch and then git worktree add --detach <excluded-dir>/main-wt origin/main, with that folder listed in .git/info/exclude so git status stays clean. To build a throwaway Go program against the repo's module, copy it into the worktree for the build and delete it afterwards so the worktree also stays clean. Named Docker volumes for the Go mod and build caches keep go mod download and build noise out of output meant for screenshots.