Re:I found a useful Git one liner buried in leaked CIA devel...
by nightpool on Friday February 20, 2026 @10:21AM
(#47089116)
`--prune` will delete your local copies of the origin's branches (e.g. `origin/whatever`). But it won't delete your local branches (e.g. `whatever` itself). So PRs that you've worked on or checked out locally will never get deleted.
Re:I found a useful Git one liner buried in leaked CIA devel...
by embedding-shape on Friday February 20, 2026 @10:42AM
(#47089432)
> Dont most git instances, like github, delete branch after a PR was merged, by default?
By default, I don't think so. And even if the branch is deleted, objects can still be there. I think GitLab has a "Clean stale objects" thing you can trigger, I don't seem to recall ever seeing any "Git Maintenance" UI actions on GitHub so not sure how it works there.
Re:I found a useful Git one liner buried in leaked CIA devel...
by Izkata on Saturday February 21, 2026 @03:56AM
(#47098845)
> I think GitLab has a "Clean stale objects" thing you can trigger
This deletes orphaned objects in commits that are unreachable after force-pushes or deleting branches or such, it doesn't delete branches itself.
Re:I found a useful Git one liner buried in leaked CIA devel...
by plqbfbv on Friday February 20, 2026 @10:20AM
(#47089112)
In Github it needs to be explicitly configured (Settings > General > Delete head branches after merging), Gitlab is the same.
A lot of my developer colleagues don't know how git works, so they have no idea that "I merged the PR" != "I deleted the feature branch". I once had to cleanup a couple repositories that had hundreds of branches spanning back 5+ years.
Nowadays I enforce it as the default project setting.
I am not sure under what usecases, you will end up with a lot of stale branches. And git fetch -pa should fix it locally