Don't store remote and local branch names in shell variables, but query
them live using git commands instead. This avoids git commands being
issued by subcommands that do not necessarily require an existing Git repo
to be initialized (i.e. git-flow init).
diff --git a/git-flow-feature b/git-flow-feature
index d65da94..af1041d 100644
--- a/git-flow-feature
+++ b/git-flow-feature
@@ -35,7 +35,7 @@
 	local feature_branches
 	local current_branch
 	local short_names
-	feature_branches=$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")
+	feature_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
 	if [ -z "$feature_branches" ]; then
 		warn "No feature branches exist."
 		exit 0
@@ -231,7 +231,7 @@
 		git fetch -q "$ORIGIN" "$BRANCH"
 	fi
 
-	if has "$ORIGIN/$BRANCH" "$REMOTE_BRANCHES"; then
+	if has "$ORIGIN/$BRANCH" "$(gitflow_remote_branches)"; then
 		gitflow_require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH"
 	fi
 	gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
diff --git a/git-flow-hotfix b/git-flow-hotfix
index 9def3af..9bfd058 100644
--- a/git-flow-hotfix
+++ b/git-flow-hotfix
@@ -32,7 +32,7 @@
 	local hotfix_branches
 	local current_branch
 	local short_names
-	hotfix_branches=$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")
+	hotfix_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
 	if [ -z "$hotfix_branches" ]; then
 		warn "No hotfix branches exist."
 		exit 0
@@ -113,7 +113,7 @@
 }
 
 require_no_existing_hotfix_branches() {
-	local hotfix_branches=$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")
+	local hotfix_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
 	local first_branch=$(echo ${hotfix_branches} | head -n1)
 	first_branch=${first_branch#$PREFIX}
 	[ -z "$hotfix_branches" ] || \
diff --git a/git-flow-release b/git-flow-release
index 602412e..e936de2 100644
--- a/git-flow-release
+++ b/git-flow-release
@@ -43,7 +43,7 @@
 	local release_branches
 	local current_branch
 	local short_names
-	release_branches=$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")
+	release_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
 	if [ -z "$release_branches" ]; then
 		warn "No release branches exist."
 		exit 0
@@ -119,7 +119,7 @@
 }
 
 require_no_existing_release_branches() {
-	local release_branches=$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")
+	local release_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
 	local first_branch=$(echo ${release_branches} | head -n1)
 	first_branch=${first_branch#$PREFIX}
 	[ -z "$release_branches" ] || \
diff --git a/git-flow-support b/git-flow-support
index 804a01d..99baf37 100644
--- a/git-flow-support
+++ b/git-flow-support
@@ -34,7 +34,7 @@
 	local support_branches
 	local current_branch
 	local short_names
-	support_branches=$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")
+	support_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
 	if [ -z "$support_branches" ]; then
 		warn "No support branches exist."
 		exit 0
diff --git a/gitflow-common b/gitflow-common
index 8efc365..93f1e7a 100644
--- a/gitflow-common
+++ b/gitflow-common
@@ -39,10 +39,10 @@
 #
 
 # get all available branches
-LOCAL_BRANCHES=$(git branch | sed 's/^[* ] //')
-REMOTE_BRANCHES=$(git branch -r | sed 's/^[* ] //')
-ALL_BRANCHES="$LOCAL_BRANCHES $REMOTE_BRANCHES"
-ALL_TAGS=$(git tag)
+gitflow_local_branches() { git branch | sed 's/^[* ] //'; }
+gitflow_remote_branches() { git branch -r | sed 's/^[* ] //'; }
+gitflow_all_branches() { gitflow_local_branches; gitflow_remote_branches; }
+gitflow_all_tags() { git tag; }
 
 #
 # resolve_nameprefix
@@ -51,8 +51,8 @@
 # $1 = name prefix to resolve
 # $2 = branch prefix to use
 #
-# Searches branch names from LOCAL_BRANCHES to look for a unique branch
-# name whose name starts with the given name prefix.
+# Searches branch names from gitflow_local_branches() to look for a unique
+# branch name whose name starts with the given name prefix.
 #
 # There are multiple exit codes possible:
 # 0: The unambiguous full name of the branch is written to stdout
@@ -67,12 +67,12 @@
 	local num_matches
 
 	# first, check if there is a perfect match
-	if has "$LOCAL_BRANCHES" "$prefix$name"; then
+	if has "$(gitflow_local_branches)" "$prefix$name"; then
 		echo "$name"
 		return 0
 	fi
 
-	matches=$(echo "$LOCAL_BRANCHES" | grep "^$prefix$name")
+	matches=$(echo "$(gitflow_local_branches)" | grep "^$prefix$name")
 	num_matches=$(echo "$matches" | wc -l)
 	if [ -z "$matches" ]; then
 		# no prefix match, so take it literally
@@ -119,37 +119,37 @@
 }
 
 gitflow_require_local_branch() {
-	if ! has $1 $LOCAL_BRANCHES; then
+	if ! has $1 $(gitflow_local_branches); then
 		die "fatal: Local branch '$1' does not exist and is required."
 	fi
 }
 
 gitflow_require_remote_branch() {
-	if ! has $1 $REMOTE_BRANCHES; then
+	if ! has $1 $(gitflow_remote_branches); then
 		die "Remote branch '$1' does not exist and is required."
 	fi
 }
 
 gitflow_require_branch() {
-	if ! has $1 $ALL_BRANCHES; then
+	if ! has $1 $(gitflow_all_branches); then
 		die "Branch '$1' does not exist and is required."
 	fi
 }
 
 gitflow_require_branch_absent() {
-	if has $1 $ALL_BRANCHES; then
+	if has $1 $(gitflow_all_branches); then
 		die "Branch '$1' already exists. Pick another name."
 	fi
 }
 
 gitflow_require_tag_absent() {
-	if has $1 $ALL_TAGS; then
+	if has $1 $(gitflow_all_tags); then
 		die "Tag '$1' already exists. Pick another name."
 	fi
 }
 
 gitflow_tag_exists() {
-	has $1 $ALL_TAGS
+	has $1 $(gitflow_all_tags)
 }
 
 #