Created
May 9, 2025 22:36
-
-
Save jeremysimmons/78cb74b475ec4a77ff4e8701d4ed5d56 to your computer and use it in GitHub Desktop.
I don't want to see me coworkers work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .git/config - local repo config | |
| # limit to only files you want to see. your branches begin with your git username by convention | |
| [remote "origin"] | |
| fetch = +refs/heads/main:refs/remotes/origin/main | |
| fetch = +refs/heads/jeremysimmons/*:refs/remotes/origin/jeremysimmons/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Exit on error | |
| set -e | |
| # Fetch latest from origin | |
| git fetch --prune | |
| echo "Cleaning up remote-tracking branches except 'origin/main' and 'origin/jeremysimmons/*'..." | |
| # List all remote-tracking branches | |
| git branch -r | while read -r remote; do | |
| # Skip origin/main and origin/jeremysimmons/* | |
| if [[ "$remote" == "origin/main" || "$remote" == origin/jeremysimmons/* ]]; then | |
| continue | |
| fi | |
| # Remove the remote-tracking branch locally | |
| # Strip "origin/" prefix to get the actual ref name | |
| ref="${remote#origin/}" | |
| echo "Deleting remote-tracking branch: $remote" | |
| git branch -dr "origin/$ref" || true | |
| done | |
| echo "Cleanup complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment