The snippet library.
Small, practical examples. Search by task or narrow things down below.
Preserve a feature branch boundary with a merge commit
Git: No-ff records a merge commit even when a fast-forward would be possible.
Git✓ Tested
Preview removal of an untracked scratch file
Git: The dry-run flag shows what clean would remove without deleting it.
Git✓ Tested
Pull without creating a merge commit
Update a branch only when its upstream can be fast-forwarded.
pull✓ Tested
Push a new branch and set its upstream
Connect a feature branch with its remote counterpart.
push✓ Tested
Push one selected release tag
Git: Naming a single tag avoids pushing every local tag unintentionally.
Git✓ Tested
Read a complete commit message
Git: The B placeholder includes the subject and body without extra metadata.
Git✓ Tested
Read a file from a commit
Inspect committed content without changing your working copy.
show✓ Tested
Read a file from the latest commit
Git: Read a file from the latest commit inside the disposable repository created by the input setup.
Git✓ Tested
Read a file from the parent commit
Git: HEAD~1 names the first parent one generation before HEAD.
Git✓ Tested
Read a repository-specific configuration value
Git: The local scope makes configuration lookup predictable for this practice repository.
Git✓ Tested
Read an annotated tag’s message
Git: for-each-ref can inspect annotation contents without including a commit diff.
Git✓ Tested
Read commit subjects affecting one file
Git: Place the path after -- so Git limits history to the selected file.
Git✓ Tested