FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

10 snippets foundClear filters
GitInspecting the working tree

Explain which ignore rule matches a file

Git: check-ignore -v reports the source file, line, pattern, and matched path.

Git✓ Tested
GitInspecting the working tree

List files tracked by Git

Git: ls-files reads the index instead of listing every file in the working directory.

Git✓ Tested
GitInspecting the working tree

List ignored untracked files

Git: Combine ignored with others so the result is specifically ignored working files.

Git✓ Tested
GitInspecting the working tree

List newly added staged files only

Git: Filter the cached diff by added status while leaving modified files out.

Git✓ Tested
GitInspecting the working tree

List only staged filenames

Git: The cached diff compares the index with HEAD rather than comparing working files with the index.

Git✓ Tested
GitInspecting the working tree

List untracked files while honoring ignore rules

Git: Use others and exclude-standard together to respect repository and global ignore configuration.

Git✓ Tested
GitInspecting the working tree

Read the exact version currently staged

Git: The colon path syntax reads a blob from the index rather than from HEAD or the working file.

Git✓ Tested
GitInspecting the working tree

Restrict a diff to one chosen path

Git: Use the double dash separator to distinguish a filename from revisions or options.

Git✓ Tested
GitInspecting the working tree

Summarize added and removed lines numerically

Git: Numstat provides tab-separated counts suitable for processing.

Git✓ Tested
GitInspecting the working tree

Test whether tracked working files changed

Git: A quiet diff returns status one for differences, so handle it in a conditional.

Git✓ Tested