LoginSignup
1
2

More than 5 years have passed since last update.

gitでcommitしたファイルの一覧を表示、vi等で簡単に開く。

Last updated at Posted at 2017-06-21

以下を.bashrcに追加

  • git log で出力したファイルの一覧をawkで成形しています。
.bashrc
function gls () {
    git log --name-status -n1 $1 | awk -F' ' '{print $2}';
}
commitしたファイルの一覧
$ gls
viで直前にcommitしたファイルを開く
$ vi `gls`
viで2つ前にcommitしたファイルを開く
$ vi `gls HEAD^`
  • ついでなので git status バージョン
.bashrc
function gs () {
    git status | grep "(modified:|new file:)" | awk -F':' '{print $2}';
}
viでcommit前のファイルの一覧
$ gs
viでcommit前のファイルを開く
$ vi `gs`
1
2
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
1
2