git ls-files
git
Usage
git ls-files [-o|-m|-i] [--exclude-standard]Lists paths from the index rather than from disk, which makes it the reliable list to script over; -i cannot stand alone and needs -c or -o plus --exclude-standard.
Common flags
| Flag | Meaning |
|---|---|
| -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 |
Examples
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
The confusion is that undo has several shapes — moving where a branch points is not the same as adding a commit that reverses it.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does git ls-files do?
Lists paths from the index rather than from disk, which makes it the reliable list to script over; -i cannot stand alone and needs -c or -o plus --exclude-standard.
Q. How do I type it?
git ls-files [-o|-m|-i] [--exclude-standard] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
8 are listed here; the full set is in man git. This command sits under git.
Related commands
man page: man git-ls-files