| name | clean-workspace |
| description | Use when asked to clean up, reset workspace, or make repo look like a fresh clone. Use after finishing feature work, merging PRs, or when workspace has stale branches and uncommitted files. |
Clean Workspace
Reset the local repo to a pristine state matching a fresh clone.
Steps
-
Stash or warn about uncommitted changes
git status -s
If there are uncommitted changes, warn the user before proceeding.
-
Switch to main and pull latest
git checkout main && git pull
-
Delete merged local branches
git branch | grep -v '^\* main$'
Delete any listed branches with git branch -d <branch>. If a branch has unmerged work, warn instead of force-deleting.
-
Remove untracked files (if any)
Only if untracked files exist and user has confirmed:
git clean -fd
-
Verify clean state
git status -s
git branch