Skip to content

Instantly share code, notes, and snippets.

@skeptrunedev
Created June 1, 2025 00:15
Show Gist options
  • Select an option

  • Save skeptrunedev/1e21290b3e4e86142c3d6c2366014a23 to your computer and use it in GitHub Desktop.

Select an option

Save skeptrunedev/1e21290b3e4e86142c3d6c2366014a23 to your computer and use it in GitHub Desktop.
remove all git worktrees which are not main
git worktree list | tail -n +2 | awk -F "[" '{print $2}' | awk -F "]" '{print $1}' | grep -v main | xargs -r -I{} git worktree remove --force {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment