Skip to content

Commit

Permalink
Check if a remote master branch exists before die, track it if no loc…
Browse files Browse the repository at this point in the history
…al master branch exists
  • Loading branch information
ejholmes committed Nov 29, 2011
1 parent 0d00b69 commit baf163e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion git-flow-init
Expand Up @@ -117,8 +117,14 @@ cmd_default() {

# 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
Expand Down

0 comments on commit baf163e

Please sign in to comment.