From 62c339eba9441dc519f83daa2ce96c243ae89730 Mon Sep 17 00:00:00 2001 From: Emre Berge Ergenekon Date: Sun, 27 Nov 2011 22:07:57 -0800 Subject: [PATCH] develop_branch uses origin/develop_branch as start-point if one exists. By default a local develop branch is created of from master regardless if a origin/develop exits. This problem is discussed in issues #137 and #23. --- git-flow-init | 6 +++++- gitflow-common | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/git-flow-init b/git-flow-init index 57ab2441e..d19b65134 100644 --- a/git-flow-init +++ b/git-flow-init @@ -200,7 +200,11 @@ cmd_default() { # default production branch and develop was "created". We should create # the develop branch now in that case (we base it on master, of course) if ! git_local_branch_exists "$develop_branch"; then - git branch --no-track "$develop_branch" "$master_branch" + if git_remote_branch_exists "origin/$develop_branch"; then + git branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1 + else + git branch --no-track "$develop_branch" "$master_branch" + fi created_gitflow_branch=1 fi diff --git a/gitflow-common b/gitflow-common index 252f5d0ea..fb515de83 100644 --- a/gitflow-common +++ b/gitflow-common @@ -97,6 +97,10 @@ git_local_branch_exists() { has $1 $(git_local_branches) } +git_remote_branch_exists() { + has $1 $(git_remote_branches) +} + git_branch_exists() { has $1 $(git_all_branches) }