book-git-commands/src/files.md

44 lines
758 B
Markdown
Raw Permalink Normal View History

2022-02-12 23:09:12 +00:00
# Files
## `ls-files`
```bash
# List files in Git.
git ls-files
git ls-files -c
```
```bash
# List modified files.
git ls-files -m
```
```bash
# List other (untracked, ignored, ...) files.
git ls-files -o
2022-10-23 17:02:49 +00:00
git ls-files --others
# List directories other files are in.
git ls-files -o --directory
2022-02-12 23:09:12 +00:00
```
```bash
# List untracked ignored files, based upon .gitignore.
git ls-files -io --exclude-from=.gitignore
```
## `cat-file`
```bash
# Pretty-print the contents of HEAD.
git cat-file -p HEAD
```
```bash
# Pretty-print the contents of a tree ID (file list), for example the tree ID from -p HEAD.
git cat-file -p <id_from_tree>
```
```bash
# Pretty-print the contents of an ID, for example the parent ID from -p HEAD.
git cat-file -p <id_from_parent>
```