The snippet library.
Small, practical examples. Search by task or narrow things down below.
Create and switch to a branch
Start an isolated feature branch from the current commit.
switch✓ Tested
Declare LF normalization for a file type
Git: A gitattributes rule records text normalization expectations for matching paths.
Git✓ Tested
Delete a chosen branch from a practice remote
Git: The delete push removes only the explicitly named remote branch.
Git✓ Tested
Delete an already merged practice branch
Git: The lowercase -d option refuses to delete an unmerged branch in ordinary use.
Git✓ Tested
Delete only a selected local tag
Git: Deleting a local tag does not delete a corresponding remote tag.
Git✓ Tested
Discard an unstaged edit to one tracked file
Git: Restore copies the index version back into the selected working file.
Git✓ Tested
Distinguish a bare repository from a working checkout
Git: rev-parse reports repository mode without relying on directory naming conventions.
Git✓ Tested
Distinguish staged changes from working edits
Git: Distinguish staged changes from working edits inside the disposable repository created by the input setup.
Git✓ Tested
Explain which ignore rule matches a file
Git: check-ignore -v reports the source file, line, pattern, and matched path.
Git✓ Tested
Export committed files without the Git metadata directory
Git: Git archive creates a snapshot of tracked committed files only.
Git✓ Tested
Fetch a remote branch
Refresh remote-tracking references before reviewing changes.
fetch✓ Tested
Filter history by its author identity
Git: The author filter selects commits by their recorded author metadata.
Git✓ Tested