14
13

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のエイリアス

Last updated at Posted at 2013-09-26

こういうエイリアスを用意しておくと、

tb =  "!sh -c \"git checkout -b `git log --pretty=\"%s\" -1 | ruby -e \"print STDIN.read.strip.gsub(/[^a-zA-Z0-9]/, '-').downcase\"`\""

直近のコミットコメントからトピックブランチを切れます。

$ touch foo
$ git add foo
$ git commit -m "Add foo, only for test/staging env"
[mster f5455b1] Add foo, only for test/staging env
 1file changed, 0 insertions(+), 0 deletions(-)
 ceate mode 100644 foo
$ git tb
Swtched to a new branch 'add-foo--only-for-test-staging-env'

追記(2014-01-21)

ブランチ名生成は別スクリプトにしました。

git-tbにパスを通しておいてください。

.gitconfig

  tb              = git-tb

git-tb

#! /usr/bin/env ruby

branch_name = `git log --pretty="%s" -1`.
  strip.
  gsub(/[^a-zA-Z0-9]/, '-').
  gsub(/--*/, '-').gsub(/^-|-$/, '').downcase

`git checkout -b #{branch_name}`
14
13
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
14
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?