简体   繁体   中英

How to remove all local git branches but keep master with one command line?

I have created many branches in local and remote. I want delete all the branch from local as well as remote.

Note:I don't want delete each and every branches one by one.

Thanks

You should make a copy of the repo, before doing this. So, that in case of any unwanted changes, you can recover easily.

You can run the following command from your repo root.

git branch --merged master | grep -v master | xargs git branch -d

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM