git ls-files
git
書き方
git ls-files [-o|-m|-i] [--exclude-standard]ディスクではなく索引に入っている経路を並べます。スクリプトで追跡ファイルを回すのに確実な一覧で、-iは単独では使えず-cか-oと--exclude-standardが要ります。
よく使うオプション
| オプション | 意味 |
|---|---|
| -c | files in the index; the default |
| -m | tracked files modified on disk |
| -d | tracked files that are missing |
| -o | files git does not track |
| -i | ignored files; must come with -o or -c and --exclude-standard |
| --exclude-standard | apply .gitignore and friends |
| -s | show mode and object id of each entry |
| -z | separate paths with NUL for xargs -0 |
例
git ls-filesevery tracked path, straight from the index
git ls-files -o --exclude-standarduntracked files only, respecting .gitignore
git ls-files -i -c --exclude-standardtracked files that .gitignore says should be ignored
取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. git ls-files は何をしますか。
ディスクではなく索引に入っている経路を並べます。スクリプトで追跡ファイルを回すのに確実な一覧で、-iは単独では使えず-cか-oと--exclude-standardが要ります。
Q. どう打ちますか。
git ls-files [-o|-m|-i] [--exclude-standard] — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは8個です。全部は man git にあります。このコマンドはgitの仲間です。
関連するコマンド
man ページ: man git-ls-files