How to delete (multiple) branches from a Git repository?

0

I want to make a fork of a repository that has dozens of branches, but I will only use 2 branches.

I wanted to know A simple way to delete all the branches that I will not use, because I've been trying to delete them but I could not.

I know that commit history is important and that I could simply use a fork of the entire project, but it turns out that there are actually many branches and most commits in the other branches have nothing to do with the ones I will use, the commit history of these does not interest me and does not affect the branches in which I will work at all.

In addition, this project for some reason does not have a master branch, so the commit history is very different in each branch.

    
asked by anonymous 18.11.2018 / 13:51

1 answer

1

You can create a Main Branch (it was supposed to be the Master, but that's fine), from a merge asking you to specify the conflicts.

git merge --no-ff nome-branch

And then you can do it here:

git branch -D 3.2 3.2.1 3.2.2

Basically, git branch will delete multiple branches for you with a single invocation. Unfortunately it does not complete the name of the agency. Although in bash you can do:

git branch -D 'git branch | grep -E '^3\.2\..*''
    
18.11.2018 / 14:03