🐈
特定Branchの特定ファイルのみを現在のBranchに取得する方法
git diff
とgit checkout
でBranchとfile-pathを指定できる。
git diff
# 1つのファイルの差分確認
git diff <target-branch> -- <file-path>
# 複数ファイルの差分確認
git diff <target-branch> -- <directory-path>/
# パターンマッチでの差分確認
git diff <target-branch> -- 'src/**/*.tsx'
git checkout
# 特定ファイルを他ブランチから取得
git checkout <target-branch> -- <file-path>
# 複数ファイル一括取得
git checkout <target-branch> -- <file1> <file2> <file3>
# ディレクトリ全体取得
git checkout <target-branch> -- <directory-path>/
# パターンマッチでの取得
git checkout <target-branch> -- 'src/**/*.tsx'
Discussion