As you work in your local clone of a git repo, you tend to create lots of topic branches. These will often get merged online via pull requests, leaving the topic branches in your local clone to languish forever. This clutters up lists of your local branches everywhere, yet deleting them can be tedious and error prone.
I wrote a tool that automates cleaning up your local branches that have already merged, reducing the tedium to just these commands:
git fetch upstream
repo git trim upstream/main
repo
is a dotnet CLI command you can install as a global tool:
dotnet tool update -g Nerdbank.DotNetRepoTools
You can repeat the above command periodically to make sure you have the latest version. Note that the update
sub-command used above works for original installation as well as updates.
This repo
tool has many other commands that are useful around git, nuget, and other common scenarios. Learn more about it here in its README:
AArnott/DotNetRepoTools: A CLI tool with commands to help maintain .NET codebases (github.com)