Aide-memoire

Git & GitHub

Les commandes indispensables pour versionner, synchroniser et corriger un projet.

InitCommitBranchesRemote
cfg

Configuration

git config --global user.name "Votre Nom"
git config --global user.email "email@example.com"
new

Creer ou cloner

git init
git clone https://github.com/nom/repo.git
add

Suivi des fichiers

git status
git add .
git commit -m "Message clair"
log

Historique

git log
git log --oneline --graph
hub

GitHub

git remote add origin https://github.com/nom/repo.git
git push -u origin main
git pull origin main
br

Branches

git branch ma-branche
git checkout ma-branche
git checkout -b nouvelle-branche
fix

Annuler

git restore fichier
git reset --hard

Attention : git reset --hard supprime les modifications locales non commitees.

cmd

Commandes utiles

CommandeUsage
git stashMettre de cote des changements
git diffVoir les differences
git tagCreer un repere de version
git reflogRetrouver des actions recentes
ok

Bonnes pratiques

  • Faire des commits petits et lisibles.
  • Verifier git status avant de commit.
  • Utiliser une branche pour chaque evolution importante.
  • Ne pas versionner .env ni node_modules.