Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only switch to develop branch if it's newly created.

  • Loading branch information...
commit 3227d8027fb14ca1922eddebd756db1fed72c8b9 1 parent 131c298
Vincent Driessen authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 git-flow-init
9 git-flow-init
@@ -144,9 +144,11 @@ cmd_default() {
# ----------------
# We create a HEAD now, if it does not exist yet (in a fresh repo). We need
# it to be able to create new branches.
+ local created_gitflow_branch=0
if ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1; then
git symbolic-ref HEAD "refs/heads/$master_branch"
git commit --allow-empty --quiet -m "Initial commit"
+ created_gitflow_branch=1
# Creation of master
@@ -163,13 +165,16 @@ cmd_default() {
# the develop branch now in that case (we base it on master, of course)
if ! gitflow_local_branch_exists "$develop_branch"; then
git branch "$develop_branch" "$master_branch"
+ created_gitflow_branch=1
# assert the gitflow repo has been correctly initialized
- # checkout the develop branch to start working
- git checkout -q "$develop_branch"
+ # switch to develop branch if its newly created
+ if [ $created_gitflow_branch -eq 1 ]; then
+ git checkout -q "$develop_branch"
+ fi
# TODO: finally, ask the user for naming convention preferences
# i.e. tag prefixes, prefixes for supporting branches, etc.
Please sign in to comment.
Something went wrong with that request. Please try again.