Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitflow
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tools
gitflow
Commits
427c5dba
Commit
427c5dba
authored
Jan 26, 2010
by
Benedikt Böhm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement init command
parent
a93a5358
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
4 deletions
+65
-4
git-flow
git-flow
+65
-4
No files found.
git-flow
View file @
427c5dba
...
@@ -22,6 +22,7 @@ export GITFLOW_DIR=$(dirname "$0")
...
@@ -22,6 +22,7 @@ export GITFLOW_DIR=$(dirname "$0")
export
MASTER_BRANCH
=
$(
git config
--get
gitflow.branch.master
||
echo
master
)
export
MASTER_BRANCH
=
$(
git config
--get
gitflow.branch.master
||
echo
master
)
export
DEVELOP_BRANCH
=
$(
git config
--get
gitflow.branch.develop
||
echo
develop
)
export
DEVELOP_BRANCH
=
$(
git config
--get
gitflow.branch.develop
||
echo
develop
)
export
ORIGIN
=
$(
git config
--get
gitflow.origin
||
echo
origin
)
export
ORIGIN
=
$(
git config
--get
gitflow.origin
||
echo
origin
)
export
README
=
$(
git config
--get
gitflow.readme
||
echo
README
)
warn
()
{
echo
"
$@
"
>
&2
;
}
warn
()
{
echo
"
$@
"
>
&2
;
}
die
()
{
warn
"
$@
"
;
exit
1
;
}
die
()
{
warn
"
$@
"
;
exit
1
;
}
...
@@ -36,6 +37,7 @@ usage() {
...
@@ -36,6 +37,7 @@ usage() {
echo
"gitflow, version
$GITFLOW_VERSION
"
echo
"gitflow, version
$GITFLOW_VERSION
"
echo
echo
echo
"usage: git flow <cmd> <type> <args>"
echo
"usage: git flow <cmd> <type> <args>"
echo
" git flow init [<url>]"
echo
echo
echo
"<type> can be any of: feature, release, hotfix, support"
echo
"<type> can be any of: feature, release, hotfix, support"
echo
echo
...
@@ -43,15 +45,20 @@ usage() {
...
@@ -43,15 +45,20 @@ usage() {
}
}
main
()
{
main
()
{
if
[
$#
-lt
2
]
;
then
if
[
$#
-lt
1
]
;
then
usage
usage
exit
1
exit
1
fi
fi
# sanity checks
# sanity checks
ACTION
=
"
$1
"
ACTION
=
"
$1
"
;
shift
BTYPE
=
"
$2
"
shift
2
if
[
"
$ACTION
"
=
"init"
]
;
then
gitflow_init
"
$@
"
exit
0
fi
BTYPE
=
"
$1
"
;
shift
if
[
!
-e
"
$GITFLOW_DIR
/git-flow-
$BTYPE
"
]
;
then
if
[
!
-e
"
$GITFLOW_DIR
/git-flow-
$BTYPE
"
]
;
then
usage
usage
...
@@ -79,6 +86,60 @@ main() {
...
@@ -79,6 +86,60 @@ main() {
cmd_
$ACTION
"
$@
"
cmd_
$ACTION
"
$@
"
}
}
gitflow_init
()
{
echo
echo
"Summary of actions:"
if
!
git rev-parse
--git-dir
&>/dev/null
;
then
git init
--quiet
echo
"- A new git repository at
$PWD
was created"
fi
if
!
git rev-parse
--quiet
--verify
HEAD
>
/dev/null
;
then
touch
$README
git add
$README
git commit
--quiet
-m
"initial commit"
if
[
"
$MASTER_BRANCH
"
!=
"master"
]
;
then
git branch
-m
master
$MASTER_BRANCH
fi
echo
"- An initial commit was created at branch '
$MASTER_BRANCH
'"
fi
if
!
git rev-parse
--verify
$MASTER_BRANCH
&>/dev/null
;
then
die
"Cannot find your master branch. Try: git branch -m <mymaster>
$MASTER_BRANCH
"
fi
gitflow_check_clean_working_tree
if
git remote |
grep
-q
$ORIGIN
;
then
git fetch
-q
$ORIGIN
gitflow_require_branches_equal
$MASTER_BRANCH
$ORIGIN
/
$MASTER_BRANCH
fi
if
git rev-parse
--verify
$DEVELOP_BRANCH
&>/dev/null
;
then
gitflow_require_branches_equal
$DEVELOP_BRANCH
$ORIGIN
/
$DEVELOP_BRANCH
else
git checkout
-q
-b
$DEVELOP_BRANCH
$MASTER_BRANCH
echo
"- A new branch '
$DEVELOP_BRANCH
' was created"
echo
"- You are now on branch '
$DEVELOP_BRANCH
'"
fi
if
!
git remote |
grep
-q
$ORIGIN
;
then
if
[
"
$1
"
=
""
]
;
then
echo
"- No remote location was added. Try: git remote add
$ORIGIN
<url>"
else
git remote add
$ORIGIN
$1
echo
"- A new remote location '
$1
' was added"
fi
fi
echo
if
git remote |
grep
-q
$ORIGIN
;
then
git push
$ORIGIN
$MASTER_BRANCH
$DEVELOP_BRANCH
fi
}
gitflow_check_clean_working_tree
()
{
gitflow_check_clean_working_tree
()
{
if
!
git diff
--no-ext-diff
--ignore-submodules
--quiet
--exit-code
;
then
if
!
git diff
--no-ext-diff
--ignore-submodules
--quiet
--exit-code
;
then
die
"Working tree contains unstaged changes. Aborting ..."
die
"Working tree contains unstaged changes. Aborting ..."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment