Home > Software engineering >  How to remove all Xcode local git branches but keep main?
How to remove all Xcode local git branches but keep main?

Time:04-09

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

enter image description here

CodePudding user response:

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.

CodePudding user response:

To remove all Xcode local git branches but keep main with a single command:

git branch | grep -v "main" | xargs git branch -D 
  • Related