2
0

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.

コミット間で変更されたファイルを列挙する

Last updated at Posted at 2016-08-23

要望: 前回のコミットで変更されたファイルを開きたい

下のコマンドで行ける形にする。git diff --name-only HEAD HEAD^を使う。

vim `diff-name`

設定方法: ワンラインで設定できる

以下のコマンドをコマンドラインに叩くか、rcファイルに記述する。

function diff-name(){if [ "$1" = "" ]; then commit=HEAD^;else commit=$1 fi;echo `git diff --name-only HEAD $commit | tr '\012' ' '`}

注意

ファイル名にスペースが入っていると期待した動作をしない。

使用例

前回のコミットから変更のあったファイルをバッファに入れてVimを起動。

vim `diff-name`

origin/masterとの間で変更のあったファイル一覧をVimで開く

vim `diff-name origin/master`

アレンジ

echoではなく、そもそもvimを起動する。

function open-vim-diff-name(){if [ "$1" = "" ]; then commit=HEAD^;else commit=$1 fi;vim `git diff --name-only HEAD $commit | tr '\012' ' '`}

参考リンク

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?