Skip to content

chore: prune stale remote-tracking refs on fetch - #17

Closed
seeones wants to merge 1 commit into
mainfrom
chore/auto-prune-branches
Closed

seeones wants to merge 1 commit into
mainfrom
chore/auto-prune-branches

Conversation

@seeones

@seeones seeones commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Summary

Enable automatic pruning of stale remote-tracking refs so the local clone stops accumulating zombie origin/* refs after GitHub deletes branches on merge.

Adds to the repository .gitconfig:

  • fetch.prune = true — every fetch/pull now removes remote-tracking refs whose branch has been deleted on the remote (e.g. GitHub's "automatically delete head branches").
  • push.autoSetupRemote = true — the first push of a new branch sets its upstream automatically.

Context

When a PR is merged with auto-delete enabled, GitHub deletes the remote branch but the local remote-tracking ref (refs/remotes/origin/<branch>) lingers until an explicit git fetch --prune. With fetch.prune this is now automatic. Note this prunes only the remote-tracking ref; the local branch itself is still kept (Git never deletes local branches implicitly) and shows [gone] as a signal to clean it up.

Testing

  • git fetch --prune origin removed the two stale refs (origin/changeset-release/main, origin/fix/marketplace-tag-on-main).
  • git config --show-origin --get fetch.prune resolves to the repository .gitconfig (included via global include.path), confirming the wiring.

Notes

  • The repository .gitconfig is consumed via a global include.path entry; the file itself is tracked so the setting travels with the repo.
  • No runtime code changes.

@seeones seeones closed this Sep 23, 2026
@seeones
seeones deleted the chore/auto-prune-branches branch September 23, 2026 05:42
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.

1 participant