_OPTIDIEN-TECH

GIT_VERSION_CONTROL

HEAD_DETACHED_PREVENTION

01_Setup

  • git init - Nouveau repo
  • git config --global user.name "N" - Nom
  • git config --global user.email "E" - Email
  • git config --global core.editor vim - Éditeur
  • git alias.lo "log --oneline" - Alias custom
  • git remote add origin [url] - Link remote

02_Workflow

  • git status - État des fichiers
  • git add . - Stager tout
  • git add -p - Stager par morceaux
  • git commit -m "msg" - Commit simple
  • git commit -am "msg" - Add + Commit
  • git commit --amend - Modifier dernier commit
  • git push origin [branch] - Envoyer
  • git pull --rebase - Pull propre

03_Branches

  • git branch - Lister branches
  • git checkout -b [n] - Créer & Switch
  • git switch [n] - Switch (moderne)
  • git merge [branch] - Fusionner
  • git branch -d [n] - Suppr branche locale
  • git push origin --delete [n] - Suppr distante
  • git branch -m [new] - Renommer actuelle

04_Inspect

  • git log --oneline --graph - Graphe ASCII
  • git diff - Diff non-staged
  • git diff --cached - Diff staged
  • git blame [file] - Qui a écrit quoi ?
  • git show [hash] - Voir un commit
  • git reflog - Historique complet

05_Undo_Reset

  • git reset HEAD [f] - Unstage fichier
  • git checkout -- [f] - Annuler modifs fichier
  • git reset --soft HEAD~1 - Undo commit (keep files)
  • git reset --hard HEAD~1 - Kill dernier commit
  • git revert [hash] - Créer commit inverse
  • git clean -df - Suppr fichiers non-suivis

06_Stash

  • git stash - Mettre de côté
  • git stash pop - Récupérer & Suppr
  • git stash list - Liste stashs
  • git stash apply [id] - Récupérer sans suppr
  • git stash clear - Vider stash

07_Adv_Tools

  • git rebase [branch] - Ré-écrire historique
  • git cherry-pick [hash] - Importer 1 commit
  • git rebase -i HEAD~3 - Squash interactif
  • git bisect start - Debug par dichotomie

08_Maint

  • git submodule add [url] - Ajouter sous-module
  • git gc --prune=now - Garbage collector
  • git remote prune origin - Clean branches dist.
  • git fetch --all - Tout récupérer