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

Synopsis

git checkout [<branch>]
git checkout -b <new-branch> [<start-point>]
git checkout [<tree-ish>] -- <file>...

Description

The git checkout command historically does two unrelated things: switching branches and restoring files. Because of this overload, modern Git introduced git switch for branch operations and git restore for file operations. git checkout still works and remains popular, but new users are encouraged to learn the newer split commands.

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

Synopsis

git branch [-a] [-r] [-v] [-d <name>] [-m <old> <new>] [<name> [<start-point>]]

Description

The git branch command manages branches. With no arguments it lists local branches and marks the current one with an asterisk. Given a name, it creates a new branch pointing at the current HEAD (or at a specified start point). It can also delete, rename, and inspect branches.

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

Synopsis

git mv [-f] [-k] [-n] <source> <destination>

Description

The git mv command renames or moves a tracked file and stages the change. Internally it is equivalent to running mv followed by git add on the new path and git rm on the old. The convenience is that the rename happens in a single atomic step that is unambiguously staged.

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

Synopsis

git rm [-f] [-r] [--cached] [--] <file>...

Description

The git rm command removes files from the working tree and the index in one step, staging the deletion for the next commit. Using git rm is more convenient than removing the file with rm and then running git add — although both approaches produce the same end state.

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

Synopsis

git diff [<options>] [<commit>] [--] [<path>...]

Description

The git diff command shows differences between two sets of file content. With no arguments, it compares the working tree against the staging area, showing what is unstaged. With --cached (or --staged), it compares the staging area against the latest commit. With one or two commit arguments, it compares those commits.

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

Synopsis

git status [-s] [-b] [--porcelain[=<version>]] [--ignored]

Description

The git status command displays the state of the working tree and the staging area. It shows which files are staged for the next commit, which are modified but not staged, and which are untracked. It also reports the current branch, whether it is ahead or behind the upstream, and any ongoing operations such as merges or rebases.

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

Synopsis

git commit [-m <msg>] [-a] [--amend] [--no-verify] [-S]

Description

The git commit command takes everything currently in the staging area and creates a new commit object in the repository. A commit is an immutable snapshot containing a tree (the file contents), parent pointer(s), author and committer metadata, and a message. Commits are the unit of history in Git: branches are pointers to commits, merges produce commits with multiple parents, and tags label specific commits.

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

Synopsis

git add [-p] [-A] [-u] [--] [<pathspec>...]

Description

The git add command moves changes from your working tree into the staging area (also called the index). The staging area is a snapshot of what will go into the next commit. By staging changes explicitly, Git lets you craft commits that contain exactly the work you want to record — even if your working tree has other unrelated edits in progress.

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

Synopsis

git clone [--branch <name>] [--depth <n>] [--recurse-submodules] <url> [directory]

Description

The git clone command copies an existing repository (typically from a remote server) into a new local directory. It performs three actions: it creates a new directory, runs git init inside it, and then fetches all branches and history from the remote. After cloning, the remote is automatically configured as origin, and the default branch is checked out into the working tree.

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

Synopsis

git init [--bare] [--initial-branch=<name>] [--template=<dir>] [directory]

Description

The git init command creates a new, empty Git repository or reinitializes an existing one. It is typically the first command you run when you want to start tracking a project with Git. The command creates a hidden .git directory containing all the metadata Git needs: the object database, references, configuration, hooks, and the index. Without this directory, Git has no place to store history.