Aide-mémoire Git
Guide de référence rapide pour les commandes Git essentielles. Aide-mémoire consultable couvrant les branches, commits, fusions et plus encore.
Flux de travail en équipe
Dans les environnements professionnels, les équipes suivent généralement une stratégie de branchement où chaque tâche a sa propre branche. Cela isole les fonctionnalités et empêche le code inachevé de casser l'application principale.
Conseils professionnels : Visez toujours des commits petits et atomiques. Avant de fusionner votre travail, utilisez 'git fetch' puis 'git rebase origin/dev' (ou main) pour vous assurer que votre code est compatible avec la dernière version. Enfin, utilisez 'git push -f' sur votre branche de fonctionnalité pour mettre à jour le distant avec votre historique rebasé.
Configuration
Définir la configuration globale
Configure votre identité sur tous les dépôts de votre système.
Commencer
Créer un dépôt git
Initialise un nouveau dépôt Git dans le répertoire actuel.
Cloner un dépôt git existant
Copie un dépôt Git existant depuis un serveur distant.
Commit
Valider tous les changements suivis
Prépare et valide tous les fichiers suivis modifiés en une seule commande.
Ajouter de nouvelles modifications au dernier commit
Met à jour le dernier commit avec les modifications actuelles et change optionnellement le message.
Branchement
Créer une nouvelle branche
Crée une nouvelle branche au pointeur actuel.
Basculer vers une branche
Déplace HEAD vers la branche spécifiée.
Fusionner une branche dans la branche actuelle
Combine l'historique d'une autre branche dans la vôtre.
Créer et basculer vers une branche
La façon la plus courante de commencer à travailler sur une nouvelle fonctionnalité.
Synchronisation
Récupérer les mises à jour du distant
Télécharge les modifications distantes sans les fusionner.
Récupérer les dernières modifications
Récupère les modifications et tente immédiatement de les fusionner.
Rebaser la branche actuelle sur main
Rejoue vos commits sur la dernière branche main.
Pousser les modifications (Force)
Force la mise à jour de la branche distante avec votre historique local. À utiliser uniquement sur les branches privées !
Commandes utiles
Vérifier le statut
Voir quels fichiers sont modifiés, préparés ou non suivis.
Mettre de côté les modifications
Cache temporairement les modifications pour travailler sur autre chose.
Voir l'historique
Visualise l'historique des commits sur toutes les branches.
Comment utiliser cet Aide-mémoire Git
- Browse the cheatsheet to find the Git command you need.
- Commands are organized by category: Configuration, Get Started, Commit, Branching, Syncing, and Useful Commands.
- Click the copy button next to any command to copy it to your clipboard.
- Paste the command into your terminal and modify the placeholder values as needed.
Advanced Rebasing
Rebasing is often preferred over merging to maintain a clean, linear project history. Instead of creating a 'merge commit', it repositions your commits at the end of the target branch.
Tip
Remember: Never rebase a public branch that others are working on, as it rewrites history and can cause significant conflicts for your peers.
Key Features
- Essential Git commands organized by workflow category
- One-click copy for every command
- Clear descriptions explaining what each command does
- Covers configuration, branching, syncing, and more
- Team workflow guidance with professional tips
- Rebasing best practices and safety warnings
- Works offline once loaded in your browser
Common Use Cases
- Quick reference while working in the terminal
- Onboarding new developers to Git workflows
- Reviewing branching and merging strategies
- Learning Git commands for the first time
- Refreshing memory on less frequently used commands
- Setting up Git configuration on a new machine
Foire Aux Questions (FAQ)
What is the difference between git merge and git rebase?
Git merge creates a new merge commit that combines two branches, preserving the full history. Git rebase replays your commits on top of the target branch, creating a linear history. Rebase produces a cleaner log but should never be used on shared public branches.
When should I use git stash?
Use git stash when you need to switch branches but have uncommitted changes you are not ready to commit. Stash saves your working directory state temporarily. You can restore it later with 'git stash pop' on any branch.
Is it safe to use git push --force?
Force pushing is safe only on branches that you alone work on, such as personal feature branches. Never force push to shared branches like main or develop, as it rewrites remote history and can cause other team members to lose their work.