10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git flow feature startで自動的に現在のブランチをベースにしてブランチを切るようにした

Last updated at Posted at 2013-01-12

git flow feature startは以下のような引数を取ります。

git flow feature start [-F] <name> [<base>]

[<base>] はオプショナルな引数なので、通常では devlop ブランチをベースにfeatureブランチが来られるようになっています。

そのため、あるfeatureブランチAに から ブランチAをベースに新しいfeatureブランチBを切るには

# 現在のブランチは branch_a
git flow feature start branch_b branch_a

というように書かかないとネストしたfeatureブランチは切ることができません。

いつも、現在のブランチを [<base>] にしてfeatureブランチを切っても問題ないと思うので、そういう動作をするシェルスクリプトを書きました。

nest branch

もうちょっとマシに書けるようにしたい…

# !/bin/bash

newBranchName=$1
echo $newBranchName
if [ $# -ne 1 ]; then
	echo "You can start a new feature branch:"
	echo " git flow feature start <name>"
  	exit 1
fi

currentBranchName=$(git rev-parse --abbrev-ref HEAD)
gitflowDevBranchName=$(git config gitflow.branch.develop)

if [ ${currentBranchName} = ${gitflowDevBranchName} ]; then
	git flow feature start ${newBranchName}
else
	git flow feature start ${newBranchName} ${currentBranchName}
fi

exit 0

動作は以下のような感じです。

codestre.am: streaming your code to the masses

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?