Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 12, 2025

This PR implements a development utility to clean up local Git branches that no longer exist in the remote repository, addressing the need for better branch management in the development workflow.

What's Added

New cleanup-branches script:

  • Executable shell script that safely removes orphaned local branches
  • Implements the command: git remote prune origin && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -d
  • Provides user-friendly output and handles edge cases (no orphaned branches found)
  • Follows the same pattern as the existing cleanup script for build artifacts

Enhanced Makefile:

  • Added make cleanup-branches target for easy access
  • Updated help output to document the new command
  • Integrated cleanly with existing development targets

Updated Documentation:

  • Added Development section to README.md explaining available developer utilities
  • Documents the branch cleanup functionality alongside other Makefile targets

Usage

Developers can now clean up stale local branches using either:

# Direct script execution
./cleanup-branches

# Via Makefile (recommended)
make cleanup-branches

The utility safely:

  1. Prunes remote tracking references to remove stale references
  2. Identifies local branches whose upstream has been deleted
  3. Removes those orphaned branches with clear user feedback

This helps maintain a clean local repository during active development by automatically removing branches that have been merged and deleted from the remote repository.

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@gvegayon gvegayon closed this Sep 12, 2025
Copilot AI changed the title [WIP] Trimming Local Branches Not Present in Remote Add Git branch cleanup utility for development workflow Sep 12, 2025
Copilot AI requested a review from gvegayon September 12, 2025 04:06
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.

2 participants