Skip to content

Commit

Permalink
Only switch to develop branch if it's newly created.
Browse files Browse the repository at this point in the history
  • Loading branch information
nvie committed Feb 20, 2010
1 parent 131c298 commit 3227d80
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions git-flow-init
Original file line number Diff line number Diff line change
Expand Up @@ -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
fi

# Creation of master
Expand All @@ -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
fi

# assert the gitflow repo has been correctly initialized
gitflow_is_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.
Expand Down

0 comments on commit 3227d80

Please sign in to comment.