Check if a remote master branch exists before die, track it if no local master branch exists
diff --git a/git-flow-init b/git-flow-init
index d19b651..4afa1c2 100644
--- a/git-flow-init
+++ b/git-flow-init
@@ -117,8 +117,14 @@
# check existence in case of an already existing repo
if [ "$should_check_existence" = "YES" ]; then
- git_local_branch_exists "$master_branch" || \
+ # if no local branch exists and a remote branch of the same
+ # name exists, checkout that branch and use it for master
+ if ! git_local_branch_exists "$master_branch" && \
+ git_remote_branch_exists "origin/$master_branch"; then
+ git branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1
+ elif ! git_local_branch_exists "$master_branch"; then
die "Local branch '$master_branch' does not exist."
+ fi
fi
# store the name of the master branch