Git Commands Cheat Sheet
Comprehensive Git command reference organized by workflow.
Setup & Config
git config --global user.name "Name"Set global usernamegit config --global user.email "email"Set global emailgit config --listList all config settingsgit initInitialize a new local repositorygit clone <url>Clone a remote repositoryStaging & Committing
git statusShow working tree statusgit add <file>Stage a specific filegit add .Stage all changesgit commit -m "message"Commit staged changes with a messagegit commit --amendModify the last commitgit diffShow unstaged changesgit diff --stagedShow staged changesBranching
git branchList all local branchesgit branch <name>Create a new branchgit checkout <branch>Switch to a branchgit checkout -b <branch>Create and switch to a new branchgit switch <branch>Switch to a branch (modern)git switch -c <branch>Create and switch to a new branch (modern)git branch -d <branch>Delete a merged branchgit branch -D <branch>Force-delete a branchgit merge <branch>Merge a branch into current branchgit rebase <branch>Rebase current branch onto anotherRemote Repositories
git remote -vList remote connectionsgit remote add origin <url>Add a remote named origingit fetchDownload remote changes without merginggit pullFetch and merge remote changesgit pull --rebaseFetch and rebase instead of mergegit push origin <branch>Push branch to remotegit push -u origin <branch>Push and set upstream trackinggit push --force-with-leaseSafe force push (checks remote)History & Log
git logShow commit historygit log --oneline --graphCompact branch graphgit log -n 10Show last 10 commitsgit log --author="name"Filter commits by authorgit blame <file>Show who changed each linegit show <commit>Show details of a specific commitUndoing Changes
git restore <file>Discard unstaged changes in a filegit restore --staged <file>Unstage a filegit reset HEAD~1Undo last commit, keep changes stagedgit reset --soft HEAD~1Undo last commit, keep changesgit reset --hard HEAD~1Undo last commit, discard changesgit revert <commit>Create a new commit that undoes a commitgit stashStash uncommitted changesgit stash popApply and remove latest stashgit stash listList all stashesTags
git tagList all tagsgit tag v1.0.0Create a lightweight taggit tag -a v1.0.0 -m "Release"Create an annotated taggit push origin --tagsPush all tags to remotegit tag -d v1.0.0Delete a local tagÀ propos de cet outil
La Référence des Commandes Git fournit un index de recherche rapide des commandes Git essentielles en sept catégories : configuration, staging et commits, branches, distants, historique, annulation des modifications et tags.
Utilisez la zone de recherche pour filtrer instantanément par nom de commande ou description. Mettez cette page en favori et revenez-y quand vous avez besoin d'un rappel rapide de syntaxe.
Comment utiliser
- Tapez un nom de commande ou un mot-clé dans la zone de recherche (ex. commit, branch, remote).
- Les commandes correspondantes sont filtrées par catégorie en temps réel.
- Consultez la commande et sa description.
- Effacez la zone de recherche pour restaurer la liste complète.
Cas d'utilisation
Les développeurs l'utilisent pour se rappeler rapidement la syntaxe des commandes Git sans quitter le navigateur. Les débutants bénéficient de la structure par catégories en apprenant Git. Utile lors des revues de code pour rechercher rapidement une opération git spécifique.
Questions fréquentes
- Pourquoi les descriptions des commandes sont-elles en anglais ? — Les commandes et les flags Git sont des standards techniques internationaux. Les garder en anglais évite les erreurs de traduction des termes techniques.
- Inclut-il toutes les commandes Git ? — Il couvre les commandes les plus couramment utilisées. Pour la référence complète, consultez la documentation officielle de git.