git checkout-index
インデックスから作業ツリーにファイルをコピーするコマンド。
用例
- 「/tmp/foo/」に管理対象外ファイルを除くGit管理ファイルを全てエクスポート
git checkout-index -a --prefix=/tmp/foo/
- 特定のコミット間で修正のあったファイルをエクスポート
git diff コミットID..コミットID --name-only | git checkout-index --prefix=./xxxxdir/ --stdin
書式
git checkout-index [options]
公式によると以下の通り。
git checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] [--stage=<number>|all] [--temp] [-z] [--stdin] [--] [<file>…]
options
-u | --index | update stat information for the checked out entries in the index file. |
-q | --quiet | be quiet if files exist or are not in the index |
-f | --force | forces overwrite of existing files |
-a | --all | checks out all files in the index. Cannot be used together with explicit filenames. |
-n | --no-create | Don’t checkout new files, only refresh files already checked out. |
--prefix=<string> | When creating files, prepend <string> (usually a directory including a trailing /) |
--stage=<number>|all | Instead of checking out unmerged entries, copy out the files from named stage. <number> must be between 1 and 3. Note: --stage=all automatically implies --temp. |
--temp | Instead of copying the files to the working directory write the content to temporary files. The temporary name associations will be written to stdout. |
--stdin | Instead of taking list of paths from the command line, read list of paths from the standard input. Paths are separated by LF (i.e. one path per line) by default. |
-z | Only meaningful with --stdin; paths are separated with NUL character instead of LF. |
-- | Do not interpret any more arguments as options. |
説明
インデックスから作業ツリーにファイルをコピーするコマンド。
ブランチをまるごとexportしたい時、圧縮せずにディレクトリに出力する場合に使用できる。
圧縮してもよいなら、 git archive のほうが、 git checkout-index より挙動にクセがなく使いやすいとの意見がある。
(git checkout-index では出力先の指定で、--prefix=/tmp/foo/ のように指定するが最後の/を忘れるとfooがファイル名とくっついてしまう等)
関連
- git archiveコマンド
参考リンク
- Git - git-checkout-index Documentation
- checkout-index - [Reference/Git] ぺんたん info
- Gitでexportするときはgit archiveとgit checkout-indexのどちらがよいか · DQNEO起業日記
- gitでsvn export的なことをやる - Qiita
- Git 管理しているプロジェクトをエクスポートする - Corredor
- 自分用のGit備忘録 - kanonji’s diary
- Gitで特定のコミット間で修正のあったファイルをエクスポートする - そうだ車輪と名づけよう 7th
その他メモ
なにかあれば。