git rebase -i をちょっと楽にするエイリアス
いつもいつも git rebase -i HEAD^^
を打つのが
めんどくさいので作ってみました。
使用例
- git irebase
- → git rebase -i HEAD~2
- git irebase 5
- → git rebase -i HEAD~5
- 数字をつけるとその数さかのぼる
- git irebase ^^^
- → git rebase -i HEAD^^^
- ^ や ~ だけの場合、 HEAD からさかのぼる
- git irebase 2 develop
- →git rebase -i HEAD~2 develop
- ブランチ指定も可
詳しくはソースを参照の事。 以下を git-irebase として PATH の通ったディレクトリに置いて使います。 https://github.com/yosugi/git-irebase にも上げておいたので、 お好きな方をどうぞ。
#!/usr/bin/env perl use strict; use warnings; sub main { my ($upstream, $branch) = @_; $upstream = 2 unless ($upstream); $branch = "" unless ($branch); if ($upstream =~ /^[0-9]+$/) { $upstream = "HEAD~$upstream"; } elsif ($upstream =~ /^[0-9^~]+$/) { $upstream = "HEAD$upstream"; } exec "git rebase -i $upstream $branch"; } main(@ARGV); __END__ =head1 NAME git-irebase - alias for git rebase -i =head1 SYNOPSIS $ git irebase [<upstream>] [<branch>] =head1 DESCRIPTION $ git clone https://github.com/yosugi/git-irebase.git $ export PATH=./git-irebase:$PATH $ git irebase =head1 AUTHOR yosugi =head1 LICENSE MIT license (http://opensource.org/licenses/mit-license.php) =cut
github のリポジトリ構造は https://github.com/kyanny/git-copy を参考にさせて もらいました。感謝です。