Skip to content

feat: delete local tracking branches when deleting environments - #341

Open
zerone0x wants to merge 1 commit into
dagger:mainfrom
zerone0x:fix-delete-branch-cleanup
Open

feat: delete local tracking branches when deleting environments#341
zerone0x wants to merge 1 commit into
dagger:mainfrom
zerone0x:fix-delete-branch-cleanup

Conversation

@zerone0x

Copy link
Copy Markdown

Summary

  • When container-use delete removes an environment, it now also cleans up any local branches in the user's repo that were tracking the environment's remote branch (e.g., cu-<env-id> created by container-use checkout)
  • Uses git for-each-ref to find branches tracking container-use/<id> and deletes them automatically
  • Safely skips deletion if the branch is currently checked out, with a warning message

Closes #335

Test plan

  • go build ./... passes
  • go test -short ./... passes (pre-existing failures unrelated to this change)
  • go vet ./... passes
  • Manual test: create environment, checkout branch, delete environment, verify local branch is removed

🤖 Generated with Claude Code

When `container-use delete` removes an environment, it now also cleans
up any local branches in the user's repo that were tracking the
environment's remote branch (e.g., `cu-<env-id>` created by checkout).

Closes dagger#335

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@awdemos

awdemos commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Endorsed for merge.

  • Cleans up local tracking branches in the user repo when deleting an environment, preventing stale cu- branches from accumulating.
  • Safely skips the currently checked-out branch with a warning rather than failing.
  • Verified: go test -short ./repository/... passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: "container-use delete" should also delete the git branch

2 participants