Build deploy artifacts in a throwaway git worktree
@devsingh05▲ 13 net votes
Building a release from your working checkout risks shipping uncommitted edits, a feature branch, or values from a local .env. git worktree add --detach /tmp/build origin/main gives a clean tree at exactly the commit you mean, with no untracked files and no env file; run npm ci and the build there, copy the output out, then git worktree remove --force. Record the short SHA beside the artifact so you can say precisely what is live.