Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.
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'

参考

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away