Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 78 lines (65 sloc) 1.963 kb
186d2b5 Vincent Driessen Refactored the subcommand invocation logic to form a more hierarchical s...
authored
1 #
2 # git-flow -- A collection of Git extensions to provide high-level
3 # repository operations for Vincent Driessen's branching model.
4 #
5 # Original blog post presenting this model is found at:
6 # http://nvie.com/archives/323
7 #
8 # Feel free to contribute to this project at:
9 # http://github.com/nvie/gitflow
10 #
11 # Copyright (c) 2010 by Vincent Driessen
12 # Copyright (c) 2010 by Benedikt Böhm
13 #
14
15 usage() {
16 echo "usage: git flow init"
17 }
18
19 # Default entry when no SUBACTION is given
20 cmd_default() {
21 echo
22 echo "Summary of actions:"
23
24 if ! git rev-parse --git-dir 2>&1 >/dev/null; then
25 git init --quiet
26 echo "- A new git repository at $PWD was created"
27 fi
28
29 if ! git rev-parse --quiet --verify HEAD 2>&1 >/dev/null; then
30 touch $README
31 git add $README
32 git commit --quiet -m "initial commit"
33 if [ "$MASTER_BRANCH" != "master" ]; then
34 git branch -m master $MASTER_BRANCH
35 fi
36 echo "- An initial commit was created at branch '$MASTER_BRANCH'"
37 fi
38
39 if ! git rev-parse --verify $MASTER_BRANCH 2>&1 >/dev/null; then
40 die "Cannot find your master branch. Try: git branch -m <mymaster> $MASTER_BRANCH"
41 fi
42
43 gitflow_check_clean_working_tree
44
45 if git remote | grep -q $ORIGIN; then
46 git fetch -q $ORIGIN
47 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
48 fi
49
50 if git rev-parse --verify $DEVELOP_BRANCH 2>&1 >/dev/null; then
51 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
52 else
53 git checkout -q -b $DEVELOP_BRANCH $MASTER_BRANCH
54 echo "- A new branch '$DEVELOP_BRANCH' was created"
55 echo "- You are now on branch '$DEVELOP_BRANCH'"
56 fi
57
58 if ! git remote | grep -q $ORIGIN; then
59 if [ "$1" = "" ]; then
60 echo "- No remote location was added. Try: git remote add $ORIGIN <url>"
61 else
62 git remote add $ORIGIN $1
63 echo "- A new remote location '$1' was added"
64 fi
65 fi
66
67 echo
68
69 if git remote | grep -q $ORIGIN; then
70 git push $ORIGIN $MASTER_BRANCH $DEVELOP_BRANCH
71 fi
72 }
73
b866b01 Vincent Driessen Give all subcommands an optional setup() function that will be called by...
authored
74 cmd_help() {
75 usage
76 exit 0
77 }
Something went wrong with that request. Please try again.