0

I'm creating a new team for git. I write this script in the shell settings. I want to delete all branches except dev and master. Help me write the correct regular expression.

# .bashrc
git() {
    if [ "$1" = "limb" ]; then
        command git branch | grep -v "master\|dev" | xargs git branch -D
    else
        command git "$@"
    fi
}

Right now, the lines just containing dev and master are being selected, but I need an exact match. The complexity of this task is also that the git branch command outputs lines with indents at the beginning of the lines.

enter image description here

oguz ismail
  • 39,105
  • 12
  • 41
  • 62
Hydrock
  • 124
  • 7

0 Answers0