Permalink
Browse files

Check if a remote master branch exists before die, track it if no loc…

…al master branch exists
  • Loading branch information...
1 parent 0d00b69 commit baf163e07d579bec3dd0e21d00297832e8848b8b @ejholmes ejholmes committed Nov 29, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 git-flow-init
View
8 git-flow-init
@@ -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

0 comments on commit baf163e

Please sign in to comment.