Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git subtree add --prefix=<path> <repo> <ref> [--squash]
git subtree pull --prefix=<path> <repo> <ref>
git subtree push --prefix=<path> <repo> <ref>
git subtree split --prefix=<path> -b <new-branch>

Description

The git subtree command is an alternative to submodules that merges another project's content directly into a subdirectory of your repo. Unlike submodules, subtree consumers don't need any special steps — the files are simply there.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git submodule add <url> <path>
git submodule update --init --recursive
git submodule foreach <cmd>

Description

The git submodule command embeds an external Git repository inside another at a fixed commit. The parent repo records the submodule URL and the exact SHA to check out, decoupling parent and child histories. This is useful for vendoring shared libraries or composing multi-repo systems.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git worktree add <path> [<branch>]
git worktree list
git worktree remove <path>
git worktree prune

Description

The git worktree command lets a single repository have multiple working trees checked out simultaneously, each at a different branch. This is faster and cheaper than cloning multiple times: only one object database, but parallel checkouts.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git filter-repo --path <path> [--invert-paths]
git filter-repo --replace-text <file>
git filter-repo --strip-blobs-bigger-than 10M

Description

The git filter-repo tool is the modern, recommended way to rewrite Git history. It replaces the deprecated git filter-branch, which is slow and error-prone.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git rebase -i <upstream>
git rebase -i --root

Description

Interactive rebase opens an editor with the list of commits to be rebased, each prefixed with an action: pick, reword, edit, squash, fixup, drop, exec, or break. By editing this list, you can reorder, combine, split, or remove commits before they go upstream. It's the workhorse of "clean up history before pushing."

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git cherry-pick [-n] [-x] [--continue] [--abort] <commit>...

Description

The git cherry-pick command applies the changes introduced by one or more existing commits onto the current branch as new commits. It's the right tool when you need a single fix from another branch without merging the entire branch. Cherry-picks create new commits with new SHAs but preserve the original author and message.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git describe --tags --dirty --always [--match 'v[0-9]*']

Description

This page covers git describe from a versioning angle: how to design a tag scheme that drives reproducible build version strings. The output of git describe is widely used by build systems (Make, CMake, Cargo, npm scripts) to generate a version string that includes a base tag plus distance and SHA.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git tag [-a] [-s] [-m <msg>] <name> [<commit>]
git tag -l ['<pattern>']
git tag -d <name>

Description

The git tag command marks specific commits with a memorable name, typically used for releases. There are two kinds of tags: lightweight (just a named pointer) and annotated (a full Git object with author, date, message, and optional GPG signature). For releases, always create annotated tags — they carry the metadata that release management requires.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git apply [--check] [--index] [--3way] <patch>...

Description

The git apply command applies a unified diff (a patch file) to the working tree, the index, or both. Unlike git am, which expects a full mailbox-format patch with author and message metadata, git apply just applies the diff content. It's useful for applying patches received over email, code review tools, or generated by git diff.

Par Anonyme (non vérifié) , 29 avril 2026

Synopsis

git stash [push [-m <msg>] [-u]]
git stash pop [<stash>]
git stash list
git stash drop [<stash>]

Description

The git stash command shelves uncommitted changes (in both working tree and index) and reverts the working tree to a clean state. The shelved changes are stored on a stack you can re-apply later. Stash is perfect for situations like "I need to switch branches but my work isn't ready to commit."