LoginSignup
6
5

More than 5 years have passed since last update.

あるコミットで変更したファイルだけの一覧を出力する

Last updated at Posted at 2015-07-01
git diff-tree --no-commit-id --name-only -r HEAD

または

git show --pretty="format:" --name-only HEAD

背景

あるコミット(今回の場合 HEAD)の中で命名した変数名を変更したいと思ったが、その変数がいたるところでヒットしたため、単純な置換だとうまくいかなかった。

そこで、変更したファイルだけを取り出して、その範囲内で置換処理を実行した。

HEADで変更したファイルに含まれるfooをbarに置換する
git diff-tree --no-commit-id --name-only -r HEAD \
  | xargs git grep -l foo \
  | xargs sed -i '' -e 's/foo/bar/g'

参考

6
5
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
6
5