3
1

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.

Git コミット間の差分ファイルを抽出してコピー

3
Last updated at Posted at 2017-10-25

コマンド

変更後を取り出し

DIR=mod; mkdir -p $DIR; \
git diff HEAD^ HEAD --name-only --diff-filter=MA | xargs -i cp --parents ./{} ./$DIR

やってること:
変更後の格納用ディレクトリを作る→差分ファイルパス一覧をxargsからcpに渡す→作成したディレクトリにコピー

変更前を取り出し

DIR=org; mkdir -p $DIR; \
git diff HEAD^ HEAD --name-only --diff-filter=MA > change.txt; \
git checkout HEAD^; cat change.txt | xargs -i cp --parents ./{} ./$DIR; \
git checkout master

master以外のブランチならmasterのところを作業中のブランチ名に置き換える

やってること:
変更前の格納用ディレクトリを作る→差分ファイルパス一覧をchange.txtに出力→ワーキングツリーを変更前の状態に戻す→change.txtの内容をxargsからcpに渡す→作成したディレクトリにコピー

なんでこんなことしたいの?

差分ファイルを手動でファイルサーバーに格納することを求められるから…

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?