From a14d9cb6eac231aec7277a45fd2d9b17c7e4e2a3 Mon Sep 17 00:00:00 2001 From: William Richard Date: Fri, 22 Oct 2021 11:19:21 -0400 Subject: [PATCH] Look for branches that are literally the word main I have a repo with many other branches that contain the string `main`, but our default branch is still master. This grep was seeing those other branches and deciding that my default branch was `main`. This tighter regex fixes that behavior for me. --- aliases/available/git.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 8cafa82b..67306064 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -199,7 +199,7 @@ function gdv() { } function get_default_branch() { - if git branch | grep -q main; then + if git branch | grep -q '^main$'; then echo main else echo master