Skip to content

Commit

Permalink
[Issue reenhanced#66] Always have reflow start create a branch from m…
Browse files Browse the repository at this point in the history
…aster
  • Loading branch information
simonzhu24 committed Apr 28, 2016
1 parent 7d181cf commit a82ccd5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 8 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ http://reenhanced.com/reflow/git-reflow-start.gif

This sets up a feature branch remotely and brings a local copy to your machine. Yeah, you can do this by hand pretty easily, so skip this command if you want. This is just a handy shortcut with no magic.

$ git reflow start nh-branch-name
git reflow start nh-branch-name

"Git Reflow Start" takes in the name of the new branch name that you want to create your feature on.
In addition, it takes in an optional flag of a base branch name. If you don't pass in this parameter, then it defaults to "master".
The base branch name is the base branch that you want to base your feature off of.
This ensures that everytime you start a new base branch, it will be based off of your latest remote base.

git reflow start nh-branch-name --base base-branch-name

[PROTIP] Use your initials at the beginning of each branch so your team knows
who is responsible for each. My initials are 'NH', so all of my branches start with +nh-+
Expand Down
14 changes: 11 additions & 3 deletions lib/git_reflow/commands/start.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@

desc 'Start will create a new feature branch and setup remote tracking'
long_desc <<LONGTIME
Performs the following:\n
\t$ git pull origin <current_branch>\n
\t$ git push origin <current_branch>:refs/heads/[new_feature_branch]\n
\t$ git checkout <base_branch>\n
\t$ git pull origin <base_branch>\n
\t$ git push origin <base_branch>:refs/heads/[new_feature_branch]\n
\t$ git checkout --track -b [new_feature_branch] origin/[new_feature_branch]\n
LONGTIME
arg_name '[new-feature-branch-name] - name of the new feature branch'
command :start do |c|
c.flag [:b,:base], default_value: 'master'
c.action do |global_options, options, args|
if args.empty?
raise "usage: git-reflow start [new-branch-name]"
else
`git pull origin #{GitReflow.current_branch}`
# base_branch is the branch that you want to base your feature branch off of
# This command allows you to 'git reflow start' off your base branch
base_branch = options[:base]

`git checkout #{base_branch}`
`git pull origin #{base_branch}`
`git push origin #{GitReflow.current_branch}:refs/heads/#{args[0]}`
`git checkout --track -b #{args[0]} origin/#{args[0]}`
end
Expand Down

0 comments on commit a82ccd5

Please sign in to comment.