'How to remove all Xcode local git branches but keep main?

I want to remove all Xcode local git branches but keep main, not manually since I have hundreds.

enter image description here



Solution 1:[1]

You can do :

  • cd <your project directory>
  • rm -rf .git

If you want add your remote repository again, you have to setup it again, but all your local branches will be deleted.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Spritrl