{"id":4269,"date":"2025-06-14T10:22:54","date_gmt":"2025-06-14T08:22:54","guid":{"rendered":"https:\/\/davidperezgar.com\/en\/?p=4269"},"modified":"2025-06-14T10:22:56","modified_gmt":"2025-06-14T08:22:56","slug":"how-to-clean-local-branches-that-no-longer-exist-in-remote-repository-with-one-command","status":"publish","type":"post","link":"https:\/\/davidperezgar.com\/en\/blog\/web-development\/how-to-clean-local-branches-that-no-longer-exist-in-remote-repository-with-one-command\/","title":{"rendered":"How to clean up local branches that no longer exist in the remote repository with a single command"},"content":{"rendered":"\n

When we work on different projects and also use the strategy that I always recommend Trunk Based development<\/a>, it is common that we create many temporary branches. Some of them are removed from the remote repository after doing merge or closing a task, but they remain in our local environment… taking up space and messing up the list of branches. It especially makes it difficult to search for the branches we are working on.<\/p>\n\n\n\n

But Git gives us a quick way to clean up those local branches that no longer have their remote equivalent. I’ll explain a command that I use frequently to leave my local repository spotless:<\/p>\n\n\n\n

\n

Tabla de contenidos<\/p>\n