# Fichier: python_cheats/cheatsheets/git_bash.txt
# Cheatsheet Git & Bash - Guide Complet Ultra-Détaillé


═══════════════════════════════════════════════════════════════════════════════
                                    GIT
═══════════════════════════════════════════════════════════════════════════════


[OK] CONFIGURATION INITIALE


# === Configuration globale (pour tous les dépôts) ===

# Identité utilisateur (OBLIGATOIRE)
git config --global user.name "Votre Nom"
git config --global user.email "votre.email@exemple.com"

# Éditeur par défaut
git config --global core.editor "vim"
git config --global core.editor "nano"
git config --global core.editor "code --wait"          # VSCode
git config --global core.editor "subl -n -w"           # Sublime Text
git config --global core.editor "atom --wait"          # Atom

# Outil de diff
git config --global diff.tool vimdiff
git config --global diff.tool meld
git config --global merge.tool vimdiff

# Couleurs (activées par défaut depuis Git 1.8.4)
git config --global color.ui auto
git config --global color.ui true

# Aliases utiles
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global alias.visual '!gitk'
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.undo 'reset --soft HEAD~1'
git config --global alias.amend 'commit --amend --no-edit'

# Comportement push
git config --global push.default simple              # Défaut moderne
git config --global push.default current             # Push branche courante
git config --global push.default matching            # Ancien comportement

# Comportement pull
git config --global pull.rebase false                # Merge (défaut)
git config --global pull.rebase true                 # Rebase
git config --global pull.ff only                     # Fast-forward uniquement

# Gestion des fins de ligne
git config --global core.autocrlf true               # Windows
git config --global core.autocrlf input              # Linux/Mac
git config --global core.autocrlf false              # Pas de conversion

# Ignorer les changements de permissions
git config --global core.fileMode false

# Cache credentials (HTTPS)
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'
git config --global credential.helper store          # Stockage permanent (moins sécurisé)
git config --global credential.helper osxkeychain    # Mac
git config --global credential.helper manager-core   # Windows

# Rebase par défaut
git config --global branch.autosetuprebase always

# Prune automatique
git config --global fetch.prune true

# === Configuration locale (dépôt spécifique) ===

# Même commandes sans --global
git config user.name "Nom Projet Spécifique"
git config user.email "email.projet@exemple.com"

# === Configuration système (tous les utilisateurs) ===
git config --system user.name "Admin"

# === Voir la configuration ===
git config --list                                    # Toute la config
git config --list --show-origin                      # Avec origine des fichiers
git config user.name                                 # Valeur spécifique
git config --global --list                           # Config globale uniquement
git config --local --list                            # Config locale uniquement

# === Éditer directement les fichiers ===
git config --global --edit                           # Ouvre ~/.gitconfig
git config --local --edit                            # Ouvre .git/config

# === Supprimer configuration ===
git config --global --unset user.name
git config --global --unset-all user.name            # Toutes les occurrences
git config --global --remove-section alias           # Section complète

# === Fichiers de configuration ===
# ~/.gitconfig                  # Global (--global)
# .git/config                   # Local (--local)
# /etc/gitconfig                # Système (--system)


[OK] INITIALISATION & CLONAGE


# === Créer nouveau dépôt ===
git init                                             # Dépôt dans dossier actuel
git init mon-projet                                  # Crée dossier et initialise
git init --bare                                      # Dépôt bare (serveur)
git init --bare --shared=group                       # Bare partagé
git init --initial-branch=main                       # Branche initiale custom
git init -b main                                     # Alias court

# === Cloner dépôt existant ===
git clone https://github.com/user/repo.git
git clone https://github.com/user/repo.git mon-dossier    # Nom custom
git clone git@github.com:user/repo.git               # SSH
git clone https://user:token@github.com/user/repo.git     # HTTPS avec token

# Options de clone
git clone --depth 1 repo.git                         # Clone shallow (dernier commit)
git clone --depth 50 repo.git                        # 50 derniers commits
git clone --branch dev repo.git                      # Clone branche spécifique
git clone -b dev repo.git                            # Alias
git clone --single-branch -b main repo.git           # Une seule branche
git clone --recurse-submodules repo.git              # Avec submodules
git clone --recursive repo.git                       # Alias
git clone --bare repo.git                            # Clone bare
git clone --mirror repo.git                          # Clone miroir
git clone --no-tags repo.git                         # Sans tags
git clone --origin upstream repo.git                 # Nom remote custom

# Cloner sous-dossier spécifique (sparse checkout)
git clone --no-checkout repo.git
cd repo
git sparse-checkout init --cone
git sparse-checkout set dossier/specifique
git checkout


[OK] ÉTAT & INFORMATIONS


# === Statut ===
git status                                           # Statut complet
git status -s                                        # Statut court
git status --short                                   # Alias
git status -sb                                       # Court + branche
git status --porcelain                               # Format machine
git status --ignored                                 # Inclut fichiers ignorés
git status -uno                                      # Sans untracked files

# Codes statut court:
# ?? = Untracked
# A  = Ajouté (staged)
# M  = Modifié
# D  = Supprimé
# R  = Renommé
# C  = Copié
# U  = Mise à jour mais non fusionné

# === Différences ===
git diff                                             # Changements non stagés
git diff --staged                                    # Changements stagés
git diff --cached                                    # Alias de --staged
git diff HEAD                                        # Tous changements vs HEAD
git diff HEAD~2                                      # vs 2 commits avant
git diff branch1..branch2                            # Entre branches
git diff branch1...branch2                           # Depuis ancêtre commun
git diff --stat                                      # Statistiques
git diff --shortstat                                 # Stats courtes
git diff --name-only                                 # Noms fichiers uniquement
git diff --name-status                               # Noms + statut
git diff --color-words                               # Diff par mots
git diff --word-diff                                 # Diff mots (alt)
git diff --check                                     # Détecte espaces problématiques
git diff fichier.txt                                 # Fichier spécifique
git diff commit1 commit2 fichier.txt                 # Fichier entre commits

# === Historique ===
git log                                              # Historique complet
git log -5                                           # 5 derniers commits
git log --oneline                                    # Format court
git log --graph                                      # Graphe ASCII
git log --all                                        # Toutes branches
git log --decorate                                   # Avec refs (branches, tags)
git log --oneline --graph --all --decorate           # Combo populaire

# Formats personnalisés
git log --pretty=oneline
git log --pretty=short
git log --pretty=full
git log --pretty=fuller
git log --pretty=format:"%h - %an, %ar : %s"
git log --pretty=format:"%C(yellow)%h%Creset %C(blue)%ad%Creset | %s %C(green)%d%Creset %C(bold red)[%an]%Creset"

# Filtres de log
git log --since="2 weeks ago"
git log --after="2024-01-01"
git log --before="2024-12-31"
git log --author="John"
git log --committer="Jane"
git log --grep="fix"                                 # Message contenant "fix"
git log -S"fonction"                                 # Contenu ajouté/supprimé
git log -G"regex.*pattern"                           # Regex dans contenu
git log --no-merges                                  # Sans merges
git log --merges                                     # Seulement merges
git log -- fichier.txt                               # Historique fichier
git log --follow fichier.txt                         # Suit renommages
git log --all -- fichier.txt                         # Toutes branches

# Stats et patches
git log --stat                                       # Avec statistiques
git log -p                                           # Avec patches complets
git log -p -2                                        # Patches 2 derniers commits
git log --patch-with-stat                            # Stats + patches

# Par branche
git log main..dev                                    # Commits dans dev pas dans main
git log main...dev                                   # Commits différents
git log dev ^main                                    # Alternative
git log --left-right main...dev                      # Avec indicateur </>

# Affichages spéciaux
git log --first-parent                               # Seulement premier parent
git log --ancestry-path                              # Chemin d'ancestralité
git log --graph --simplify-by-decoration --all       # Branches simplifiées

# === Afficher commit spécifique ===
git show                                             # Dernier commit
git show HEAD                                        # Dernier commit
git show HEAD~2                                      # 2 commits avant
git show abc1234                                     # Commit par hash
git show main:fichier.txt                            # Fichier dans branche
git show main~3:path/to/file                         # Fichier commit spécifique
git show --stat                                      # Avec stats
git show --name-only                                 # Noms fichiers uniquement
git show --pretty=fuller                             # Format complet

# === Références ===
git reflog                                           # Historique références (local)
git reflog show HEAD                                 # Reflog de HEAD
git reflog show main                                 # Reflog branche
git reflog --all                                     # Toutes les refs
git reflog --date=iso                                # Avec dates ISO

# === Blame (qui a modifié quoi) ===
git blame fichier.txt                                # Annotations ligne par ligne
git blame -L 10,20 fichier.txt                       # Lignes 10 à 20
git blame -L 10,+5 fichier.txt                       # 5 lignes depuis ligne 10
git blame -C fichier.txt                             # Détecte copies
git blame -M fichier.txt                             # Détecte déplacements
git blame -w fichier.txt                             # Ignore espaces
git blame --date=short fichier.txt                   # Format date court

# === Recherche ===
git grep "pattern"                                   # Cherche dans working tree
git grep "pattern" main                              # Cherche dans branche
git grep -n "pattern"                                # Avec numéros lignes
git grep -c "pattern"                                # Compte occurrences
git grep -i "pattern"                                # Insensible casse
git grep --break --heading "pattern"                 # Format lisible
git grep -e "pattern1" --and -e "pattern2"           # ET logique
git grep -e "pattern1" --or -e "pattern2"            # OU logique

# === Informations dépôt ===
git remote -v                                        # Remotes configurés
git remote show origin                               # Détails remote
git branch -a                                        # Toutes les branches
git tag                                              # Tous les tags
git describe                                         # Description position
git describe --tags                                  # Avec tags
git describe --always                                # Toujours sortie
git rev-parse HEAD                                   # Hash complet HEAD
git rev-parse --short HEAD                           # Hash court
git rev-parse --abbrev-ref HEAD                      # Nom branche actuelle


[OK] STAGING (INDEX)


# === Ajouter fichiers ===
git add fichier.txt                                  # Fichier spécifique
git add *.py                                         # Pattern
git add dossier/                                     # Dossier complet
git add .                                            # Tous fichiers courants
git add -A                                           # Tous (ajouts, modifs, suppressions)
git add --all                                        # Alias
git add -u                                           # Seulement tracked modifiés
git add --update                                     # Alias
git add -p                                           # Mode patch interactif
git add --patch                                      # Alias
git add -i                                           # Mode interactif
git add --interactive                                # Alias
git add --ignore-removal .                           # Sans suppressions
git add --force fichier.txt                          # Force (même si .gitignore)
git add -f fichier.txt                               # Alias

# Mode interactif (git add -i)
# 1: status      - Statut
# 2: update      - Mettre à jour
# 3: revert      - Annuler stage
# 4: add untracked - Ajouter non-trackés
# 5: patch       - Mode patch
# 6: diff        - Voir diff staged
# 7: quit        - Quitter

# Mode patch (git add -p)
# y - Stage ce hunk
# n - Ne pas stage ce hunk
# q - Quitter
# a - Stage ce hunk et tous suivants du fichier
# d - Ne pas stage ce hunk ni suivants
# s - Diviser hunk en plus petits
# e - Éditer manuellement hunk
# ? - Aide

# === Retirer du staging ===
git reset fichier.txt                                # Unstage fichier
git reset HEAD fichier.txt                           # Équivalent
git reset                                            # Unstage tous
git restore --staged fichier.txt                     # Nouvelle syntaxe
git restore --staged .                               # Tous fichiers

# === Voir ce qui est stagé ===
git diff --staged
git diff --cached
git status


[OK] COMMIT


# === Commits basiques ===
git commit                                           # Ouvre éditeur
git commit -m "Message"                              # Message inline
git commit -m "Titre" -m "Description"               # Multi-ligne
git commit -am "Message"                             # Add + commit (tracked uniquement)
git commit --all -m "Message"                        # Alias

# === Commits avancés ===
git commit --amend                                   # Modifier dernier commit
git commit --amend -m "Nouveau message"              # Amend avec nouveau message
git commit --amend --no-edit                         # Amend sans changer message
git commit --amend --author="Nom <email>"            # Changer auteur
git commit --amend --date="Wed Nov 13 12:00 2024"    # Changer date
git commit --allow-empty -m "Commit vide"            # Commit sans changements
git commit --allow-empty-message                     # Commit sans message
git commit -v                                        # Verbose (montre diff)
git commit --verbose                                 # Alias

# === Template de message ===
git commit --template=.gitmessage.txt                # Utilise template
git config --global commit.template ~/.gitmessage.txt  # Template permanent

# === Commits partiels ===
git commit fichier1.txt fichier2.txt -m "Message"    # Fichiers spécifiques
git commit -p                                        # Mode patch
git commit --patch                                   # Alias

# === Co-auteurs ===
git commit -m "Message" -m "Co-authored-by: Nom <email>"

# === GPG Signing ===
git commit -S -m "Message"                           # Signe commit
git commit --gpg-sign -m "Message"                   # Alias
git config --global commit.gpgsign true              # Toujours signer
git config --global user.signingkey KEYID            # Clé par défaut

# === Fixup & Autosquash ===
git commit --fixup=abc1234                           # Fixup pour commit
git commit --squash=abc1234                          # Squash pour commit
git rebase -i --autosquash HEAD~5                    # Applique auto

# === Message conventions ===
# Format classique:
# type(scope): sujet court (50 chars max)
#
# Description détaillée (72 chars par ligne max)
#
# Footer (refs, breaking changes, etc.)

# Types communs:
# feat:     Nouvelle fonctionnalité
# fix:      Correction bug
# docs:     Documentation
# style:    Formatage, virgules, etc.
# refactor: Refactorisation
# test:     Tests
# chore:    Maintenance, config, etc.
# perf:     Performance
# ci:       Intégration continue
# build:    Build système
# revert:   Annule commit précédent

# Exemples:
# feat(auth): ajoute authentification OAuth
# fix(api): corrige endpoint /users
# docs: met à jour README
# refactor(core)!: change API publique
#
# BREAKING CHANGE: L'API a changé


[OK] BRANCHES


# === Lister branches ===
git branch                                           # Branches locales
git branch -a                                        # Toutes (locales + remotes)
git branch --all                                     # Alias
git branch -r                                        # Seulement remotes
git branch -v                                        # Avec dernier commit
git branch -vv                                       # Avec tracking info
git branch --merged                                  # Branches mergées
git branch --merged main                             # Mergées dans main
git branch --no-merged                               # Non mergées
git branch --contains abc1234                        # Contiennent commit
git branch --sort=-committerdate                     # Tri par date

# === Créer branches ===
git branch nouvelle-branche                          # Crée branche
git branch nouvelle-branche main                     # Depuis branche
git branch nouvelle-branche abc1234                  # Depuis commit
git checkout -b nouvelle-branche                     # Crée et switch
git checkout -b nouvelle main                        # Crée depuis main
git switch -c nouvelle-branche                       # Nouvelle syntaxe
git switch -c nouvelle main                          # Depuis main

# === Changer de branche ===
git checkout main                                    # Switch branche
git checkout -                                       # Branche précédente
git switch main                                      # Nouvelle syntaxe
git switch -                                         # Branche précédente

# === Renommer branches ===
git branch -m ancien-nom nouveau-nom                 # Renomme autre branche
git branch -m nouveau-nom                            # Renomme branche actuelle
git branch --move ancien nouveau                     # Alias

# === Supprimer branches ===
git branch -d nom-branche                            # Supprime (safe)
git branch --delete nom-branche                      # Alias
git branch -D nom-branche                            # Force suppression
git branch --delete --force nom-branche              # Alias
git push origin --delete nom-branche                 # Supprime remote
git push origin :nom-branche                         # Syntaxe alternative

# === Tracking branches ===
git branch -u origin/main                            # Set upstream
git branch --set-upstream-to=origin/main             # Alias
git branch --unset-upstream                          # Enlève upstream
git checkout -b locale origin/remote                 # Track remote
git checkout --track origin/remote                   # Alias simplifié
git checkout remote                                  # Auto-track si existe remote

# === Comparer branches ===
git diff main..dev                                   # Différences
git diff main...dev                                  # Depuis ancêtre commun
git log main..dev                                    # Commits dans dev
git log main...dev                                   # Commits différents
git log --left-right main...dev                      # Avec direction
git cherry main dev                                  # Commits à cherry-pick


[OK] MERGE


# === Merge basique ===
git merge branche                                    # Merge dans branche actuelle
git merge branche -m "Message"                       # Avec message custom
git merge --no-ff branche                            # Force commit merge
git merge --ff-only branche                          # Fast-forward uniquement
git merge --squash branche                           # Squash en un commit
git merge --no-commit branche                        # Prépare sans commiter

# === Stratégies de merge ===
git merge -s recursive branche                       # Stratégie récursive (défaut)
git merge -s ours branche                            # Garde notre version
git merge -s theirs branche                          # N'existe pas, utiliser -X
git merge -X ours branche                            # Préfère notre version en conflit
git merge -X theirs branche                          # Préfère leur version
git merge -X patience branche                        # Algorithme patient
git merge -X ignore-space-change branche             # Ignore espaces
git merge -X ignore-all-space branche                # Ignore tous espaces
git merge -X rename-threshold=50% branche            # Seuil détection renommage

# === Conflits ===
git status                                           # Voir conflits
git diff                                             # Voir différences
git diff --ours                                      # Notre version
git diff --theirs                                    # Leur version
git diff --base                                      # Version commune

# Marques dans fichier:
# <<<<<<< HEAD
# Notre version
# =======
# Leur version
# >>>>>>> branche

git checkout --ours fichier.txt                      # Prend notre version
git checkout --theirs fichier.txt                    # Prend leur version
git add fichier.txt                                  # Marque résolu
git merge --continue                                 # Continue merge
git merge --abort                                    # Annule merge
git merge --quit                                     # Quitte sans annuler

# === Outils de merge ===
git mergetool                                        # Lance outil configuré
git mergetool --tool=vimdiff                         # Outil spécifique
git mergetool --tool=meld
git mergetool --tool=kdiff3

# === Informations merge ===
git log --merge                                      # Log des conflits
git log --merge -p fichier.txt                       # Avec patches


[OK] REBASE


# === Rebase basique ===
git rebase main                                      # Rebase sur main
git rebase main branche                              # Rebase branche sur main
git rebase --onto nouvelle ancienne courante         # Rebase onto

# === Rebase interactif ===
git rebase -i HEAD~5                                 # 5 derniers commits
git rebase -i abc1234                                # Depuis commit
git rebase -i main                                   # Depuis branche
git rebase --interactive HEAD~3                      # Alias

# Commandes rebase interactif:
# pick    = Utilise commit
# reword  = Utilise commit, édite message
# edit    = Utilise commit, arrête pour amend
# squash  = Utilise commit, fusionne avec précédent
# fixup   = Comme squash, jette message
# exec    = Exécute commande shell
# break   = Arrête ici (continue avec 'git rebase --continue')
# drop    = Supprime commit
# label   = Labellise commit
# reset   = Réinitialise à label
# merge   = Crée merge commit

# === Options rebase ===
git rebase --continue                                # Continue après conflit
git rebase --skip                                    # Skip commit conflictuel
git rebase --abort                                   # Annule rebase
git rebase --quit                                    # Quitte sans annuler
git rebase --edit-todo                               # Édite TODO list
git rebase --show-current-patch                      # Montre patch actuel
git rebase --autosquash                              # Auto-squash fixup/squash
git rebase --autostash                               # Stash auto avant rebase
git rebase --keep-empty                              # Garde commits vides
git rebase --preserve-merges                         # Préserve merges (deprecated)
git rebase --rebase-merges                           # Rebase avec merges
git rebase -x "npm test"                             # Exec après chaque commit
git rebase --exec "npm test"                         # Alias

# === Rebase avancé ===
git rebase --onto main branche1 branche2             # Rebase branche2 de branche1 vers main
git rebase --root --interactive                      # Rebase depuis premier commit
git rebase -i --autosquash HEAD~10                   # Auto-arrange fixup/squash

# === Résolution conflits ===
# 1. Résoudre conflit
# 2. git add fichier
# 3. git rebase --continue

git checkout --ours fichier.txt                      # Notre version
git checkout --theirs fichier.txt                    # Leur version
git add fichier.txt
git rebase --continue


[OK] RESET


# === Types de reset ===
git reset --soft HEAD~1                              # Garde staging et working
git reset --mixed HEAD~1                             # Garde working (défaut)
git reset --hard HEAD~1                              # Supprime tout

# === Reset à commit spécifique ===
git reset abc1234                                    # Reset à commit
git reset --soft abc1234                             # Soft reset
git reset --hard abc1234                             # Hard reset
git reset HEAD~3                                     # 3 commits avant
git reset main                                       # Reset à branche

# === Reset fichiers ===
git reset fichier.txt                                # Unstage fichier
git reset HEAD fichier.txt                           # Équivalent
git reset --hard fichier.txt                         # Restaure fichier

# === Différence soft/mixed/hard ===
# --soft   : HEAD bouge, Index intact, Working intact
# --mixed  : HEAD bouge, Index reset, Working intact (défaut)
# --hard   : HEAD bouge, Index reset, Working reset ([ATTENTION] DANGEREUX)

# === Récupérer après reset ===
git reflog                                           # Voir historique
git reset --hard abc1234                             # Reset à ancien commit


[OK] RESTORE & REVERT


# === Restore (Git 2.23+) ===
git restore fichier.txt                              # Restaure working tree
git restore --staged fichier.txt                     # Unstage fichier
git restore --source=HEAD~2 fichier.txt              # Depuis commit
git restore --source=main fichier.txt                # Depuis branche
git restore --worktree fichier.txt                   # Explicite working tree
git restore --staged --worktree fichier.txt          # Les deux
git restore .                                        # Tous fichiers
git restore --patch fichier.txt                      # Mode interactif

# === Revert (annule commit) ===
git revert abc1234                                   # Crée commit inverse
git revert HEAD                                      # Dernier commit
git revert HEAD~3                                    # 3ème avant dernier
git revert abc1234..def5678                          # Range de commits
git revert --no-commit abc1234                       # Prépare sans commit
git revert -n abc1234                                # Alias
git revert --continue                                # Continue après conflit
git revert --abort                                   # Annule revert
git revert --quit                                    # Quitte sans annuler
git revert -m 1 abc1234                              # Revert merge (parent 1)
git revert -m 2 abc1234                              # Parent 2


[OK] STASH


# === Stash basique ===
git stash                                            # Stash changements
git stash push                                       # Alias moderne
git stash save "Message"                             # Avec message (deprecated)
git stash push -m "Message"                          # Avec message (moderne)

# === Options stash ===
git stash -u                                         # Include untracked
git stash --include-untracked                        # Alias
git stash -a                                         # Include tous (untracked + ignored)
git stash --all                                      # Alias
git stash -k                                         # Garde staged
git stash --keep-index                               # Alias
git stash -p                                         # Mode patch
git stash --patch                                    # Alias

# === Stash fichiers spécifiques ===
git stash push fichier.txt                           # Fichier spécifique
git stash push -m "Message" fichier1.txt fichier2.txt

# === Lister stashes ===
git stash list                                       # Liste tous stashes
git stash list --stat                                # Avec stats
git stash show                                       # Montre dernier stash
git stash show stash@{0}                             # Stash spécifique
git stash show -p stash@{1}                          # Avec patch
git stash show --stat stash@{2}                      # Avec stats

# === Appliquer stashes ===
git stash pop                                        # Applique et supprime dernier
git stash pop stash@{2}                              # Stash spécifique
git stash apply                                      # Applique sans supprimer
git stash apply stash@{1}                            # Stash spécifique
git stash apply --index                              # Réapplique staging

# === Gérer stashes ===
git stash drop                                       # Supprime dernier
git stash drop stash@{2}                             # Supprime spécifique
git stash clear                                      # Supprime tous
git stash branch nouvelle-branche                    # Crée branche depuis stash
git stash branch nouvelle stash@{1}                  # Depuis stash spécifique

# === Créer stash avancé ===
git stash store -m "Message" $(git stash create)     # Crée sans appliquer


[OK] TAGS


# === Créer tags ===
git tag v1.0.0                                       # Tag léger
git tag -a v1.0.0 -m "Version 1.0.0"                 # Tag annoté
git tag -a v1.0.0 -m "Release" abc1234               # Tag sur commit
git tag -s v1.0.0 -m "Version signée"                # Tag signé (GPG)

# === Lister tags ===
git tag                                              # Tous les tags
git tag -l                                           # Alias
git tag --list                                       # Alias
git tag -l "v1.*"                                    # Pattern
git tag -n                                           # Avec 1 ligne annotation
git tag -n5                                          # Avec 5 lignes
git show v1.0.0                                      # Détails tag

# === Supprimer tags ===
git tag -d v1.0.0                                    # Supprime local
git tag --delete v1.0.0                              # Alias
git push origin --delete v1.0.0                      # Supprime remote
git push origin :refs/tags/v1.0.0                    # Syntaxe alternative

# === Push tags ===
git push origin v1.0.0                               # Push tag spécifique
git push origin --tags                               # Push tous tags
git push --tags                                      # Alias
git push --follow-tags                               # Push tags annotés seulement

# === Checkout tags ===
git checkout v1.0.0                                  # Checkout tag (detached HEAD)
git checkout -b branche v1.0.0                       # Crée branche depuis tag

# === Renommer tags ===
git tag nouveau ancien                               # Copie tag
git tag -d ancien                                    # Supprime ancien
git push origin :refs/tags/ancien                    # Supprime remote
git push origin nouveau                              # Push nouveau


[OK] REMOTES


# === Gérer remotes ===
git remote                                           # Liste remotes
git remote -v                                        # Avec URLs
git remote --verbose                                 # Alias
git remote add origin https://github.com/user/repo.git  # Ajoute remote
git remote add upstream https://github.com/original/repo.git
git remote rename origin nouveau-nom                 # Renomme
git remote remove origin                             # Supprime
git remote rm origin                                 # Alias
git remote set-url origin https://nouvelle-url.git   # Change URL
git remote set-url --add origin https://autre.git    # Ajoute URL push
git remote set-url --delete origin https://url.git   # Supprime URL

# === Informations remote ===
git remote show origin                               # Détails remote
git remote get-url origin                            # URL fetch
git remote get-url --push origin                     # URL push
git remote get-url --all origin                      # Toutes URLs

# === Remote branches ===
git remote update                                    # Met à jour refs remotes
git remote update origin                             # Remote spécifique
git remote prune origin                              # Supprime refs obsolètes
git remote prune origin --dry-run                    # Preview


[OK] FETCH, PULL, PUSH


# === Fetch ===
git fetch                                            # Fetch default remote
git fetch origin                                     # Fetch origin
git fetch --all                                      # Fetch tous remotes
git fetch origin main                                # Branche spécifique
git fetch origin tag v1.0.0                          # Tag spécifique
git fetch --prune                                    # Supprime refs obsolètes
git fetch -p                                         # Alias
git fetch --tags                                     # Fetch tous tags
git fetch --no-tags                                  # Sans tags
git fetch --depth=50                                 # Shallow fetch
git fetch --unshallow                                # Convertit en full

# === Pull ===
git pull                                             # Fetch + merge
git pull origin main                                 # Remote et branche
git pull --rebase                                    # Fetch + rebase
git pull -r                                          # Alias
git pull --ff-only                                   # Fast-forward seulement
git pull --no-ff                                     # Force merge commit
git pull --all                                       # Tous remotes
git pull --tags                                      # Avec tags
git pull --depth=1                                   # Shallow pull
git pull --autostash                                 # Stash auto

# === Push ===
git push                                             # Push branche actuelle
git push origin main                                 # Remote et branche
git push origin branche:remote-branche               # Noms différents
git push -u origin main                              # Push et set upstream
git push --set-upstream origin main                  # Alias
git push --all                                       # Toutes branches
git push --tags                                      # Tous tags
git push --follow-tags                               # Tags annotés
git push --force                                     # Force push ([ATTENTION] DANGEREUX)
git push -f                                          # Alias
git push --force-with-lease                          # Force safe
git push --force-with-lease=main:abc1234             # Avec ref
git push --delete origin branche                     # Supprime branche remote
git push origin :branche                             # Syntaxe alternative
git push --dry-run                                   # Simulation
git push -n                                          # Alias
git push --no-verify                                 # Skip hooks
git push --atomic                                    # Tout ou rien
git push --signed                                    # Push signé
git push --mirror                                    # Mirror ([ATTENTION] force tout)

# === Upstream tracking ===
git push -u origin branche                           # Set upstream
git branch --set-upstream-to=origin/main             # Explicite
git branch -u origin/main                            # Alias


[OK] CHERRY-PICK


# === Cherry-pick basique ===
git cherry-pick abc1234                              # Applique commit
git cherry-pick abc1234 def5678                      # Plusieurs commits
git cherry-pick abc1234..def5678                     # Range (exclusif début)
git cherry-pick abc1234^..def5678                    # Range (inclusif)
git cherry-pick main~3                               # Depuis position

# === Options ===
git cherry-pick --edit abc1234                       # Édite message
git cherry-pick -e abc1234                           # Alias
git cherry-pick --no-commit abc1234                  # Prépare sans commit
git cherry-pick -n abc1234                           # Alias
git cherry-pick -x abc1234                           # Ajoute note origine
git cherry-pick --signoff abc1234                    # Ajoute Signed-off-by
git cherry-pick -s abc1234                           # Alias
git cherry-pick -m 1 abc1234                         # Merge commit (parent 1)

# === Gestion conflits ===
git cherry-pick --continue                           # Continue après conflit
git cherry-pick --skip                               # Skip commit
git cherry-pick --abort                              # Annule cherry-pick
git cherry-pick --quit                               # Quitte sans annuler

# === Cherry-pick avancé ===
git cherry-pick --strategy=recursive abc1234
git cherry-pick -X theirs abc1234                    # Stratégie conflit
git cherry-pick --allow-empty abc1234                # Permet commit vide
git cherry-pick --keep-redundant-commits abc1234     # Garde même si vide


[OK] SUBMODULES


# === Ajouter submodule ===
git submodule add https://github.com/user/repo.git
git submodule add https://github.com/user/repo.git path/to/module
git submodule add -b branche https://url.git path    # Branche spécifique
git submodule add --name nom https://url.git path    # Nom custom

# === Initialiser submodules ===
git submodule init                                   # Initialise
git submodule update                                 # Télécharge
git submodule update --init                          # Init + update
git submodule update --init --recursive              # Récursif
git clone --recurse-submodules https://url.git       # Clone avec submodules
git clone --recursive https://url.git                # Alias

# === Mettre à jour submodules ===
git submodule update --remote                        # MAJ depuis remote
git submodule update --remote module-name            # Submodule spécifique
git submodule update --merge                         # Merge changements
git submodule update --rebase                        # Rebase changements
git submodule foreach git pull origin main           # Commande dans chaque

# === Informations submodules ===
git submodule status                                 # Statut
git submodule status --recursive                     # Récursif
git submodule summary                                # Résumé changements
git config --file=.gitmodules -l                     # Config submodules

# === Supprimer submodule ===
git submodule deinit path/to/module                  # Dé-initialise
git submodule deinit -f path/to/module               # Force
git rm path/to/module                                # Supprime
rm -rf .git/modules/path/to/module                   # Nettoie cache

# === Commandes foreach ===
git submodule foreach 'git checkout main'
git submodule foreach 'git pull'
git submodule foreach --recursive 'commande'


[OK] WORKTREE


# === Créer worktree ===
git worktree add ../hotfix                           # Crée worktree
git worktree add ../hotfix branche                   # Depuis branche
git worktree add ../hotfix -b nouvelle               # Nouvelle branche
git worktree add --detach ../detached abc1234        # Detached HEAD
git worktree add -b branche --no-checkout ../path    # Sans checkout

# === Lister worktrees ===
git worktree list                                    # Liste worktrees
git worktree list --porcelain                        # Format machine

# === Supprimer worktree ===
git worktree remove ../hotfix                        # Supprime
git worktree remove --force ../hotfix                # Force
git worktree prune                                   # Nettoie refs

# === Informations ===
git worktree lock ../hotfix                          # Verrouille
git worktree unlock ../hotfix                        # Déverrouille
git worktree move ../old ../new                      # Déplace
git worktree repair                                  # Répare


[OK] BISECT (RECHERCHE DICHOTOMIQUE)


# === Démarrer bisect ===
git bisect start                                     # Démarre session
git bisect bad                                       # Marque HEAD comme bad
git bisect bad abc1234                               # Commit bad spécifique
git bisect good def5678                              # Marque commit good
git bisect good v1.0                                 # Tag good

# === Processus bisect ===
# À chaque étape:
git bisect good                                      # Si OK
git bisect bad                                       # Si bug
git bisect skip                                      # Si impossible tester
# Répéter jusqu'à trouver le commit

# === Terminer bisect ===
git bisect reset                                     # Retourne à HEAD original
git bisect reset branche                             # Retourne à branche

# === Bisect automatique ===
git bisect start HEAD v1.0
git bisect run ./test.sh                             # Script de test
# Le script doit retourner 0 si bon, 1-127 si mauvais (sauf 125 = skip)

# === Bisect avancé ===
git bisect start --no-checkout                       # Sans checkout
git bisect log                                       # Voir log bisect
git bisect replay bisect.log                         # Rejoue session
git bisect visualize                                 # Visualise
git bisect view                                      # Alias
git bisect terms                                     # Voir termes (good/bad)
git bisect terms --term-new broken --term-old fixed  # Termes custom


[OK] CLEAN


# === Nettoyer fichiers ===
git clean -n                                         # Dry-run (preview)
git clean --dry-run                                  # Alias
git clean -f                                         # Supprime untracked files
git clean --force                                    # Alias
git clean -fd                                        # Fichiers + dossiers
git clean -fx                                        # + fichiers ignorés
git clean -fdx                                       # Tout sauf .git
git clean -fX                                        # Seulement fichiers ignorés
git clean -i                                         # Mode interactif
git clean --interactive                              # Alias
git clean -e "*.log"                                 # Exclut pattern
git clean -x -d -n                                   # Preview complet

# === Clean interactif ===
# 1: clean               - Nettoyer
# 2: filter by pattern   - Filtrer
# 3: select by numbers   - Sélectionner
# 4: ask each            - Demander chaque
# 5: quit                - Quitter
# 6: help                - Aide


[OK] ARCHIVES


# === Créer archives ===
git archive HEAD > archive.tar                       # Archive HEAD
git archive HEAD --format=zip > archive.zip          # Format zip
git archive HEAD --format=tar.gz > archive.tar.gz    # Tar gzip
git archive -o archive.zip HEAD                      # Output avec -o
git archive HEAD src/ > src.tar                      # Dossier spécifique
git archive --prefix=projet/ HEAD > archive.tar      # Avec préfixe
git archive v1.0.0 > release.tar                     # Depuis tag
git archive --remote=origin HEAD > archive.tar       # Depuis remote

# === Options ===
git archive --format=zip --prefix=v1.0/ HEAD > v1.0.zip
git archive --output=output.zip HEAD


[OK] BUNDLE


# === Créer bundles ===
git bundle create repo.bundle HEAD                   # Bundle HEAD
git bundle create repo.bundle --all                  # Tout
git bundle create repo.bundle main                   # Branche
git bundle create repo.bundle main dev               # Plusieurs branches
git bundle create repo.bundle --tags                 # Avec tags
git bundle create repo.bundle v1.0..HEAD             # Range

# === Vérifier bundle ===
git bundle verify repo.bundle                        # Vérifie intégrité
git bundle list-heads repo.bundle                    # Liste branches

# === Utiliser bundles ===
git clone repo.bundle mon-dossier                    # Clone depuis bundle
git fetch repo.bundle main:local-main                # Fetch depuis bundle
git pull repo.bundle main                            # Pull depuis bundle


[OK] MAINTENANCE & OPTIMISATION


# === Garbage collection ===
git gc                                               # Garbage collection
git gc --aggressive                                  # Aggressive GC
git gc --auto                                        # Auto GC
git gc --prune=now                                   # Prune immédiat
git prune                                            # Prune objets

# === Fsck (vérification) ===
git fsck                                             # Vérifie intégrité
git fsck --full                                      # Vérification complète
git fsck --unreachable                               # Objets inaccessibles
git fsck --lost-found                                # Récupère objets perdus

# === Count objects ===
git count-objects                                    # Compte objets
git count-objects -v                                 # Verbose
git count-objects -vH                                # Human readable

# === Repack ===
git repack                                           # Repack objets
git repack -a                                        # Tous objets
git repack -A                                        # Garde unreachable
git repack -d                                        # Supprime vieux packs
git repack -f                                        # Force repack
git repack -a -d -f --depth=250 --window=250         # Optimal

# === Maintenance moderne (Git 2.30+) ===
git maintenance start                                # Active maintenance auto
git maintenance stop                                 # Désactive
git maintenance run                                  # Exécute manuellement
git maintenance run --task=gc                        # Tâche spécifique
git maintenance register                             # Enregistre dépôt
git maintenance unregister                           # Désenregistre


[OK] REFLOG & RÉCUPÉRATION


# === Reflog ===
git reflog                                           # Historique local complet
git reflog show HEAD                                 # Reflog HEAD
git reflog show main                                 # Reflog branche
git reflog show --all                                # Toutes refs
git reflog show --date=iso HEAD                      # Avec dates
git reflog expire --expire=90.days --all            # Expire vieilles entrées
git reflog delete HEAD@{2}                           # Supprime entrée

# === Récupération données perdues ===
# Après git reset --hard accidentel
git reflog                                           # Trouve hash commit perdu
git reset --hard abc1234                             # Reset à commit trouvé

# Récupérer branche supprimée
git reflog                                           # Trouve dernier commit branche
git checkout -b branche-recuperee abc1234            # Recrée branche

# Récupérer commit détaché
git reflog                                           # Trouve commit
git branch branche-perdue abc1234                    # Crée branche

# Objets perdus
git fsck --lost-found                                # Trouve objets perdus
git show abc1234                                     # Examine objet
git merge abc1234                                    # Récupère


[OK] HOOKS


# Hooks disponibles (dans .git/hooks/)

# === Côté client ===
# pre-commit              - Avant commit
# prepare-commit-msg      - Prépare message commit
# commit-msg              - Valide message commit
# post-commit             - Après commit
# pre-rebase              - Avant rebase
# post-checkout           - Après checkout
# post-merge              - Après merge
# pre-push                - Avant push
# pre-auto-gc             - Avant auto garbage collection

# === Côté serveur ===
# pre-receive             - Avant réception push
# update                  - Pour chaque branche poussée
# post-receive            - Après réception push

# === Exemple pre-commit hook ===
#!/bin/bash
# .git/hooks/pre-commit

# Lance tests
npm test
if [ $? -ne 0 ]; then
    echo "Tests échoués, commit annulé"
    exit 1
fi

# Vérifie formatage
black --check .
if [ $? -ne 0 ]; then
    echo "Formatage incorrect, commit annulé"
    exit 1
fi

exit 0

# Rendre exécutable
chmod +x .git/hooks/pre-commit

# === Exemple commit-msg hook ===
#!/bin/bash
# .git/hooks/commit-msg

# Vérifie format message (Conventional Commits)
COMMIT_MSG=$(cat "$1")
PATTERN="^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,}"

if ! echo "$COMMIT_MSG" | grep -qE "$PATTERN"; then
    echo "[X] Message commit invalide!"
    echo "Format: type(scope): message"
    echo "Types: feat, fix, docs, style, refactor, test, chore"
    exit 1
fi

exit 0

# === Bypass hooks ===
git commit --no-verify                               # Skip hooks
git commit -n                                        # Alias


[OK] ATTRIBUTS (.gitattributes)


# Fichier .gitattributes dans racine projet

# === Normalisation fins de ligne ===
* text=auto                                          # Auto-détection
*.txt text                                           # Toujours texte
*.jpg binary                                         # Binaire
*.sh text eol=lf                                     # Unix LF
*.bat text eol=crlf                                  # Windows CRLF

# === Diff personnalisés ===
*.ipynb diff=jupyternotebook                         # Jupyter
*.pdf diff=pdf                                       # PDF
*.docx diff=word                                     # Word

# === Merge personnalisés ===
database.db merge=ours                               # Garde toujours notre version
*.json merge=union                                   # Union simple

# === Filtres ===
*.secret filter=secret                               # Applique filtre

# === Linguist (GitHub) ===
docs/* linguist-documentation                        # Marque comme doc
vendor/* linguist-vendored                           # Code vendeur
*.js linguist-language=JavaScript                    # Force langage

# === Export ignore ===
test/ export-ignore                                  # Ignore dans archives
.gitattributes export-ignore
.gitignore export-ignore


[OK] GITIGNORE


# Fichier .gitignore

# === Patterns basiques ===
fichier.txt                                          # Fichier spécifique
*.log                                                # Extension
dossier/                                             # Dossier
**/cache                                             # cache partout
node_modules/                                        # Node.js
__pycache__/                                         # Python
*.pyc                                                # Python compiled
.DS_Store                                            # macOS
Thumbs.db                                            # Windows
.env                                                 # Variables env
.vscode/                                             # VSCode
.idea/                                               # IntelliJ

# === Patterns avancés ===
!important.log                                       # Exception (ne pas ignorer)
/*.txt                                               # Seulement racine
**/build                                             # build dans tous sous-dossiers
doc/**/*.txt                                         # Tous .txt dans doc/

# === Forcer ajout fichier ignoré ===
git add -f fichier-ignore.txt                        # Force add

# === Templates gitignore ===
# https://github.com/github/gitignore
# Templates par langage/framework

# === Ignorer fichiers localement ===
# .git/info/exclude (non versionné)
# Même syntaxe que .gitignore

# === Ignorer globalement ===
git config --global core.excludesfile ~/.gitignore_global


[OK] ALIAS BASH POUR GIT


# Ajouter à ~/.bashrc ou ~/.zshrc

# === Alias courts ===
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gb='git branch'
alias gba='git branch -a'
alias gc='git commit'
alias gcm='git commit -m'
alias gca='git commit --amend'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gd='git diff'
alias gds='git diff --staged'
alias gf='git fetch'
alias gl='git log'
alias glo='git log --oneline'
alias glg='git log --graph --oneline --all'
alias gm='git merge'
alias gp='git push'
alias gpl='git pull'
alias gr='git rebase'
alias gri='git rebase -i'
alias grs='git reset'
alias grh='git reset --hard'
alias gs='git status'
alias gss='git status -s'
alias gst='git stash'
alias gstp='git stash pop'

# === Alias avancés ===
alias glog='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
alias gwip='git add -A && git commit -m "WIP"'
alias gundo='git reset --soft HEAD~1'
alias gclean='git clean -fd'
alias gpristine='git reset --hard && git clean -fdx'

# === Fonctions bash ===
# Créer branche et push
function gnb() {
    git checkout -b "$1"
    git push -u origin "$1"
}

# Commit rapide
function gac() {
    git add --all
    git commit -m "$1"
}

# Commit et push
function gacp() {
    git add --all
    git commit -m "$1"
    git push
}

# Voir fichiers modifiés dans commit
function gshow() {
    git show --stat "$1"
}


[OK] CONFIGURATION AVANCÉE


# === Performance ===
git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256
git config --global pack.threads 0                   # Auto CPU threads

# === Sécurité ===
git config --global transfer.fsckobjects true
git config --global fetch.fsckobjects true
git config --global receive.fsckobjects true

# === Diff & Merge ===
git config --global diff.algorithm histogram
git config --global merge.conflictstyle diff3        # Montre base commune
git config --global merge.ff false                   # No fast-forward par défaut
git config --global rerere.enabled true              # Reuse recorded resolution

# === Affichage ===
git config --global log.date relative
git config --global log.date iso
git config --global format.pretty oneline
git config --global pager.branch false               # Pas de pager pour branch

# === URLs ===
git config --global url."git@github.com:".insteadOf "https://github.com/"

# === GPG ===
git config --global commit.gpgsign true
git config --global tag.gpgsign true
git config --global user.signingkey KEYID

# === LFS (Large File Storage) ===
git lfs install                                      # Installer LFS
git lfs track "*.psd"                                # Tracker fichiers
git lfs ls-files                                     # Lister fichiers LFS
git lfs pull                                         # Pull fichiers LFS


[OK] WORKFLOWS COURANTS


# === Feature Branch Workflow ===
git checkout main
git pull origin main
git checkout -b feature/nouvelle-fonctionnalite
# ... développement ...
git add .
git commit -m "feat: ajoute nouvelle fonctionnalité"
git push -u origin feature/nouvelle-fonctionnalite
# Créer Pull Request
# Après review et merge
git checkout main
git pull origin main
git branch -d feature/nouvelle-fonctionnalite

# === Gitflow ===
# Branches: main, develop, feature/*, release/*, hotfix/*

# Nouvelle feature
git checkout develop
git checkout -b feature/ma-feature
# ... développement ...
git checkout develop
git merge --no-ff feature/ma-feature
git branch -d feature/ma-feature
git push origin develop

# Release
git checkout develop
git checkout -b release/1.2.0
# ... préparation release ...
git checkout main
git merge --no-ff release/1.2.0
git tag -a v1.2.0
git checkout develop
git merge --no-ff release/1.2.0
git branch -d release/1.2.0

# Hotfix
git checkout main
git checkout -b hotfix/1.2.1
# ... fix ...
git checkout main
git merge --no-ff hotfix/1.2.1
git tag -a v1.2.1
git checkout develop
git merge --no-ff hotfix/1.2.1
git branch -d hotfix/1.2.1

# === Fork & Pull Request ===
# 1. Fork sur GitHub
# 2. Clone ton fork
git clone https://github.com/ton-user/repo.git
cd repo

# 3. Ajoute upstream
git remote add upstream https://github.com/original/repo.git

# 4. Crée branche
git checkout -b feature

# 5. Développe et commit
git add .
git commit -m "feat: nouvelle feature"

# 6. Sync avec upstream
git fetch upstream
git rebase upstream/main

# 7. Push vers ton fork
git push origin feature

# 8. Crée Pull Request sur GitHub

# 9. Après merge, clean
git checkout main
git pull upstream main
git push origin main
git branch -d feature


[OK] RÉSOLUTION PROBLÈMES COURANTS


# === Annuler dernier commit (non pushé) ===
git reset --soft HEAD~1                              # Garde changements stagés
git reset HEAD~1                                     # Garde changements unstaged
git reset --hard HEAD~1                              # Supprime tout ([ATTENTION])

# === Modifier message dernier commit ===
git commit --amend -m "Nouveau message"

# === Ajouter fichier oublié au dernier commit ===
git add fichier-oublie.txt
git commit --amend --no-edit

# === Annuler commit pushé ===
git revert HEAD                                      # Crée commit inverse
git revert abc1234                                   # Commit spécifique

# === Récupérer fichier d'une autre branche ===
git checkout autre-branche -- fichier.txt

# === Supprimer fichier de Git mais pas du disque ===
git rm --cached fichier.txt

# === Supprimer dossier de Git ===
git rm -r --cached dossier/
echo "dossier/" >> .gitignore
git add .gitignore
git commit -m "Remove dossier from git"

# === Changer l'origine (remote URL) ===
git remote set-url origin https://nouvelle-url.git

# === Réinitialiser à remote ===
git fetch origin
git reset --hard origin/main

# === Forcer push ([ATTENTION] DANGEREUX) ===
git push --force-with-lease                          # Safer
git push -f                                          # Force ([ATTENTION])

# === Fusionner commits (squash) ===
git rebase -i HEAD~3                                 # 3 derniers commits
# Changer 'pick' en 'squash' pour les commits à fusionner

# === Changer auteur commit ===
git commit --amend --author="Nom <email>"
# Pour plusieurs commits:
git rebase -i HEAD~3
# Changer 'pick' en 'edit'
# Pour chaque:
git commit --amend --author="Nom <email>" --no-edit
git rebase --continue

# === Supprimer données sensibles ===
# Avec git filter-repo (recommandé)
pip install git-filter-repo
git filter-repo --path passwords.txt --invert-paths

# Avec BFG Repo Cleaner
java -jar bfg.jar --delete-files passwords.txt
git reflog expire --expire=now --all
git gc --prune=now --aggressive

# === Résoudre "detached HEAD" ===
git checkout main                                    # Retour à branche
# Ou créer branche depuis position actuelle
git checkout -b nouvelle-branche

# === Conflit lors de pull ===
git pull                                             # Conflit
# Résoudre fichiers
git add fichiers-resolus.txt
git commit                                           # Ou git merge --continue

# === Annuler merge en cours ===
git merge --abort

# === Annuler rebase en cours ===
git rebase --abort

# === Récupérer après git clean accidentel ===
# Impossible si pas committé - toujours utiliser -n d'abord!

# === Large file error lors de push ===
git lfs install
git lfs track "*.psd"
git add .gitattributes
git add fichier.psd
git commit --amend
git push


[OK] OUTILS & INTERFACES


# === GUI Clients ===
# GitKraken          - https://www.gitkraken.com/
# GitHub Desktop     - https://desktop.github.com/
# Sourcetree         - https://www.sourcetreeapp.com/
# Tower              - https://www.git-tower.com/
# SmartGit           - https://www.syntevo.com/smartgit/
# GitExtensions      - https://gitextensions.github.io/

# === CLI Tools ===
gitk                                                 # Visualiseur intégré (Tcl/Tk)
git gui                                              # GUI intégré
tig                                                  # Interface ncurses
lazygit                                              # TUI moderne
# Installation lazygit:
# Mac: brew install lazygit
# Linux: sudo apt install lazygit
# Windows: scoop install lazygit

# === Extensions ===
# gh (GitHub CLI)      - https://cli.github.com/
gh auth login
gh repo clone user/repo
gh pr create
gh pr list
gh issue list

# git-extras           - https://github.com/tj/git-extras
git-ignore python                                    # Génère .gitignore
git-info                                             # Info dépôt
git-undo                                             # Undo dernier commit
git-archive-file                                     # Archive avec format auto

# delta                - Meilleur diff viewer
# Installation: brew install git-delta
git config --global core.pager delta
git config --global interactive.diffFilter "delta --color-only"


═══════════════════════════════════════════════════════════════════════════════
                                    BASH
═══════════════════════════════════════════════════════════════════════════════


[OK] NAVIGATION & FICHIERS


# === Navigation ===
pwd                                                  # Print working directory
cd /chemin/absolu                                    # Chemin absolu
cd chemin/relatif                                    # Chemin relatif
cd                                                   # Retour home (~)
cd ~                                                 # Home explicite
cd -                                                 # Dossier précédent
cd ..                                                # Dossier parent
cd ../..                                             # 2 niveaux au-dessus
cd ~/Documents                                       # Home + sous-dossier
pushd /chemin                                        # Push et change dir
popd                                                 # Retour dir précédent
dirs                                                 # Affiche stack dirs
dirs -v                                              # Avec numéros
dirs -c                                              # Clear stack

# === Lister fichiers ===
ls                                                   # Liste fichiers
ls -l                                                # Format long
ls -la                                               # Long + cachés
ls -lh                                               # Human readable
ls -lS                                               # Tri par taille
ls -lt                                               # Tri par date modif
ls -ltr                                              # Tri par date (inverse)
ls -R                                                # Récursif
ls -d */                                             # Seulement dossiers
ls -1                                                # Un par ligne
ls -i                                                # Affiche inodes
ls -lah --color=auto                                 # Avec couleurs
ls *.txt                                             # Pattern
ls -lA                                               # Sans . et ..
ll                                                   # Alias pour ls -la (souvent)

# Options utiles:
# -a : Tous fichiers (cachés inclus)
# -h : Human readable (Ko, Mo, Go)
# -l : Format long
# -r : Ordre inverse
# -t : Tri par date modif
# -S : Tri par taille
# -R : Récursif

tree                                                 # Arborescence
tree -L 2                                            # Profondeur 2
tree -a                                              # Avec cachés
tree -d                                              # Seulement dossiers
tree -I 'node_modules|.git'                          # Ignore patterns

# === Créer dossiers ===
mkdir dossier                                        # Crée dossier
mkdir -p parent/enfant/petit-enfant                  # Crée parents si besoin
mkdir dossier1 dossier2 dossier3                     # Plusieurs dossiers
mkdir -m 755 dossier                                 # Avec permissions
mkdir -v dossier                                     # Verbose

# === Supprimer ===
rm fichier.txt                                       # Supprime fichier
rm -f fichier.txt                                    # Force (no prompt)
rm -i fichier.txt                                    # Interactif (demande)
rm -v fichier.txt                                    # Verbose
rm *.txt                                             # Pattern
rm -r dossier                                        # Récursif (dossier)
rm -rf dossier                                       # Force récursif ([ATTENTION] DANGEREUX)
rmdir dossier                                        # Supprime dossier vide
rmdir -p parent/enfant/vide                          # Récursif dossiers vides

# === Copier ===
cp source.txt destination.txt                        # Copie fichier
cp source.txt /chemin/destination/                   # Dans dossier
cp -r dossier/ destination/                          # Récursif (dossiers)
cp -a dossier/ destination/                          # Archive (préserve tout)
cp -i source.txt dest.txt                            # Interactif
cp -u source.txt dest.txt                            # Seulement si plus récent
cp -v source.txt dest.txt                            # Verbose
cp -p source.txt dest.txt                            # Préserve attributs
cp fichier{,.bak}                                    # Copie avec extension
# Équivalent: cp fichier fichier.bak

# === Déplacer/Renommer ===
mv ancien.txt nouveau.txt                            # Renomme fichier
mv fichier.txt /autre/dossier/                       # Déplace fichier
mv dossier/ /autre/emplacement/                      # Déplace dossier
mv -i source.txt dest.txt                            # Interactif
mv -f source.txt dest.txt                            # Force
mv -n source.txt dest.txt                            # No clobber (ne remplace pas)
mv -v source.txt dest.txt                            # Verbose
mv *.txt dossier/                                    # Pattern vers dossier

# === Liens ===
ln -s /chemin/source lien                            # Lien symbolique
ln -s $(pwd)/fichier.txt ~/lien                      # Lien absolu
ln fichier lien                                      # Lien dur (hard link)
readlink lien                                        # Lit destination lien
readlink -f lien                                     # Chemin absolu
unlink lien                                          # Supprime lien

# === Toucher fichiers ===
touch fichier.txt                                    # Crée fichier vide / MAJ timestamp
touch -a fichier.txt                                 # MAJ access time
touch -m fichier.txt                                 # MAJ modification time
touch -d "2024-01-01 12:00" fichier.txt              # Date spécifique
touch -r reference.txt fichier.txt                   # Copie timestamp

# === Trouver fichiers ===
find . -name "*.txt"                                 # Par nom
find . -iname "*.TXT"                                # Insensible casse
find . -type f                                       # Seulement fichiers
find . -type d                                       # Seulement dossiers
find . -type l                                       # Seulement liens
find . -size +10M                                    # Plus de 10Mo
find . -size -1k                                     # Moins de 1Ko
find . -mtime -7                                     # Modifiés derniers 7 jours
find . -mtime +30                                    # Modifiés il y a plus de 30j
find . -user username                                # Par utilisateur
find . -perm 644                                     # Par permissions
find . -empty                                        # Fichiers/dossiers vides
find . -name "*.txt" -delete                         # Trouve et supprime
find . -name "*.txt" -exec rm {} \;                  # Exec commande
find . -name "*.txt" -exec chmod 644 {} \;           # Change permissions
find . -type f -name "*.log" -exec grep -l "error" {} \;  # Grep dans résultats
find . -maxdepth 2 -name "*.py"                      # Profondeur max
find . -mindepth 2 -name "*.py"                      # Profondeur min
find . -path "./node_modules" -prune -o -name "*.js" -print  # Exclut chemin

# locate (plus rapide mais base de données)
locate fichier.txt                                   # Cherche dans DB
sudo updatedb                                        # Met à jour DB locate

# which (cherche dans PATH)
which python                                         # Trouve exécutable
which -a python                                      # Tous les chemins

# whereis (cherche binaire, source, man)
whereis python                                       # Info complète


[OK] AFFICHAGE & CONTENU FICHIERS


# === Cat (afficher) ===
cat fichier.txt                                      # Affiche contenu
cat file1.txt file2.txt                              # Plusieurs fichiers
cat file1.txt file2.txt > combined.txt               # Concatène
cat -n fichier.txt                                   # Avec numéros lignes
cat -b fichier.txt                                   # Numéros lignes non-vides
cat -s fichier.txt                                   # Supprime lignes vides multiples
cat -A fichier.txt                                   # Affiche tous caractères

# === Less & More (pagination) ===
less fichier.txt                                     # Paginateur (mieux que more)
# Navigation less:
# espace   : Page suivante
# b        : Page précédente
# /pattern : Chercher
# n        : Occurrence suivante
# N        : Occurrence précédente
# g        : Début fichier
# G        : Fin fichier
# q        : Quitter

more fichier.txt                                     # Paginateur basique
less +F fichier.txt                                  # Mode follow (comme tail -f)
less +G fichier.txt                                  # Ouvre à la fin

# === Head & Tail ===
head fichier.txt                                     # 10 premières lignes
head -n 20 fichier.txt                               # 20 premières lignes
head -5 fichier.txt                                  # 5 premières lignes
head -c 100 fichier.txt                              # 100 premiers bytes

tail fichier.txt                                     # 10 dernières lignes
tail -n 20 fichier.txt                               # 20 dernières lignes
tail -5 fichier.txt                                  # 5 dernières lignes
tail -f fichier.log                                  # Follow (temps réel)
tail -F fichier.log                                  # Follow avec retry
tail -n +10 fichier.txt                              # Depuis ligne 10

# === Wc (word count) ===
wc fichier.txt                                       # Lignes, mots, caractères
wc -l fichier.txt                                    # Compte lignes
wc -w fichier.txt                                    # Compte mots
wc -c fichier.txt                                    # Compte bytes
wc -m fichier.txt                                    # Compte caractères
wc -L fichier.txt                                    # Ligne la plus longue
ls | wc -l                                           # Compte fichiers

# === Nl (number lines) ===
nl fichier.txt                                       # Numérote lignes
nl -ba fichier.txt                                   # Toutes lignes
nl -bt fichier.txt                                   # Sauf lignes vides

# === Tac (inverse cat) ===
tac fichier.txt                                      # Affiche à l'envers

# === Rev (reverse lines) ===
rev fichier.txt                                      # Inverse chaque ligne


[OK] RECHERCHE & FILTRAGE


# === Grep (recherche) ===
grep "pattern" fichier.txt                           # Cherche pattern
grep "error" *.log                                   # Dans plusieurs fichiers
grep -i "pattern" fichier.txt                        # Insensible casse
grep -v "pattern" fichier.txt                        # Inverse (lignes sans)
grep -n "pattern" fichier.txt                        # Avec numéros lignes
grep -c "pattern" fichier.txt                        # Compte occurrences
grep -l "pattern" *.txt                              # Noms fichiers uniquement
grep -L "pattern" *.txt                              # Fichiers sans pattern
grep -r "pattern" dossier/                           # Récursif
grep -R "pattern" .                                  # Récursif avec liens
grep -w "word" fichier.txt                           # Mot entier
grep -x "ligne exacte" fichier.txt                   # Ligne exacte
grep -A 3 "pattern" fichier.txt                      # +3 lignes après
grep -B 3 "pattern" fichier.txt                      # +3 lignes avant
grep -C 3 "pattern" fichier.txt                      # +3 lignes autour
grep -E "regex|pattern" fichier.txt                  # Regex étendue
grep -P "perl regex" fichier.txt                     # Regex Perl
grep -o "pattern" fichier.txt                        # Seulement match
grep -e "pat1" -e "pat2" fichier.txt                 # Plusieurs patterns
grep --color=auto "pattern" fichier.txt              # Avec couleur
grep -m 5 "pattern" fichier.txt                      # Max 5 résultats
grep -q "pattern" fichier.txt                        # Quiet (exit status)
grep -s "pattern" fichier.txt                        # Supprime erreurs
grep -H "pattern" *.txt                              # Avec noms fichiers
grep -h "pattern" *.txt                              # Sans noms fichiers

# Grep avancé
grep "^start" fichier.txt                            # Début de ligne
grep "end$" fichier.txt                              # Fin de ligne
grep "^$" fichier.txt                                # Lignes vides
grep "[0-9]" fichier.txt                             # Contient chiffre
grep "^[A-Z]" fichier.txt                            # Commence par majuscule
ps aux | grep python                                 # Processus python
grep -r "TODO" --include="*.py" .                    # Seulement .py
grep -r "pattern" --exclude="*.log" .                # Exclut .log
grep -r "pattern" --exclude-dir=node_modules .       # Exclut dossier

# === Egrep (grep étendu) ===
egrep "pattern1|pattern2" fichier.txt                # OU
egrep "pattern+" fichier.txt                         # Regex étendue

# === Fgrep (grep fixe) ===
fgrep "literal.string" fichier.txt                   # Pas de regex

# === Awk (traitement texte) ===
awk '{print $1}' fichier.txt                         # 1ère colonne
awk '{print $NF}' fichier.txt                        # Dernière colonne
awk '{print $1, $3}' fichier.txt                     # Colonnes 1 et 3
awk 'NR==5' fichier.txt                              # Ligne 5
awk 'NR>=5 && NR<=10' fichier.txt                    # Lignes 5 à 10
awk '/pattern/' fichier.txt                          # Lignes avec pattern
awk '/pattern/ {print $2}' fichier.txt               # 2ème colonne si pattern
awk '{sum+=$1} END {print sum}' fichier.txt          # Somme colonne 1
awk '{print NF}' fichier.txt                         # Nombre champs par ligne
awk 'length($0) > 80' fichier.txt                    # Lignes > 80 chars
awk -F: '{print $1}' /etc/passwd                     # Séparateur custom
awk 'BEGIN {FS=":"} {print $1}' /etc/passwd          # Alternative
awk '{print NR ": " $0}' fichier.txt                 # Numéros lignes
awk '!seen[$0]++' fichier.txt                        # Lignes uniques
awk '{for(i=NF;i>=1;i--) printf "%s ", $i; print ""}' file  # Inverse colonnes

# === Sed (stream editor) ===
sed 's/ancien/nouveau/' fichier.txt                  # Remplace 1ère occurrence
sed 's/ancien/nouveau/g' fichier.txt                 # Remplace toutes
sed 's/ancien/nouveau/gi' fichier.txt                # Insensible casse
sed 's/ancien/nouveau/2' fichier.txt                 # 2ème occurrence
sed -i 's/ancien/nouveau/g' fichier.txt              # Modifie fichier (in-place)
sed -i.bak 's/ancien/nouveau/g' fichier.txt          # Avec backup
sed '5d' fichier.txt                                 # Supprime ligne 5
sed '5,10d' fichier.txt                              # Supprime lignes 5-10
sed '/pattern/d' fichier.txt                         # Supprime lignes avec pattern
sed -n '5p' fichier.txt                              # Affiche ligne 5
sed -n '5,10p' fichier.txt                           # Affiche lignes 5-10
sed -n '/pattern/p' fichier.txt                      # Affiche lignes avec pattern
sed '5a\Nouvelle ligne' fichier.txt                  # Ajoute après ligne 5
sed '5i\Nouvelle ligne' fichier.txt                  # Insère avant ligne 5
sed '5c\Remplace ligne' fichier.txt                  # Remplace ligne 5
sed 's/^/PREFIX /' fichier.txt                       # Préfixe chaque ligne
sed 's/$/ SUFFIX/' fichier.txt                       # Suffixe chaque ligne
sed '/^$/d' fichier.txt                              # Supprime lignes vides
sed 's/  */ /g' fichier.txt                          # Remplace espaces multiples

# === Cut (colonnes) ===
cut -d: -f1 /etc/passwd                              # 1ère colonne (délimiteur :)
cut -d' ' -f1,3 fichier.txt                          # Colonnes 1 et 3
cut -c1-10 fichier.txt                               # Caractères 1 à 10
cut -c1,5,10 fichier.txt                             # Caractères 1, 5 et 10
cut -f1 --complement fichier.txt                     # Toutes sauf 1ère

# === Sort (tri) ===
sort fichier.txt                                     # Tri alphabétique
sort -r fichier.txt                                  # Tri inverse
sort -n fichier.txt                                  # Tri numérique
sort -h fichier.txt                                  # Tri human-numeric
sort -k2 fichier.txt                                 # Tri par 2ème colonne
sort -k2,2 -k1,1 fichier.txt                         # Multi-colonnes
sort -t: -k3 -n /etc/passwd                          # Délimiteur custom
sort -u fichier.txt                                  # Tri et unique
sort -f fichier.txt                                  # Ignore casse
sort -M fichier.txt                                  # Tri par mois
sort -R fichier.txt                                  # Tri aléatoire

# === Uniq (unique) ===
uniq fichier.txt                                     # Supprime doublons consécutifs
sort fichier.txt | uniq                              # Lignes uniques
uniq -c fichier.txt                                  # Compte occurrences
uniq -d fichier.txt                                  # Seulement doublons
uniq -u fichier.txt                                  # Seulement uniques
uniq -i fichier.txt                                  # Ignore casse
uniq -f 1 fichier.txt                                # Skip 1er champ

# === Tr (translate) ===
tr 'a-z' 'A-Z' < fichier.txt                         # Minuscules -> Majuscules
tr 'A-Z' 'a-z' < fichier.txt                         # Majuscules -> Minuscules
tr -d '0-9' < fichier.txt                            # Supprime chiffres
tr -s ' ' < fichier.txt                              # Squeeze espaces
tr ' ' '\n' < fichier.txt                            # Espace -> Nouvelle ligne
tr -cd '[:print:]' < fichier.txt                     # Garde seulement printable

# === Comm (compare) ===
comm file1.txt file2.txt                             # Compare fichiers triés
comm -12 file1.txt file2.txt                         # Lignes communes
comm -23 file1.txt file2.txt                         # Seulement dans file1
comm -13 file1.txt file2.txt                         # Seulement dans file2

# === Diff (différences) ===
diff file1.txt file2.txt                             # Différences
diff -u file1.txt file2.txt                          # Format unifié
diff -y file1.txt file2.txt                          # Côte à côte
diff -r dir1/ dir2/                                  # Récursif dossiers
diff -q file1.txt file2.txt                          # Quiet (juste si différent)
diff -i file1.txt file2.txt                          # Ignore casse
diff -w file1.txt file2.txt                          # Ignore espaces
diff -b file1.txt file2.txt                          # Ignore changements espaces


[OK] REDIRECTION & PIPES


# === Redirection sortie ===
commande > fichier.txt                               # Redirige stdout (écrase)
commande >> fichier.txt                              # Append stdout
commande 2> erreurs.txt                              # Redirige stderr
commande 2>> erreurs.txt                             # Append stderr
commande > output.txt 2>&1                           # stdout et stderr
commande &> output.txt                               # stdout et stderr (court)
commande > output.txt 2> erreurs.txt                 # Séparés
commande > /dev/null                                 # Supprime output
commande 2> /dev/null                                # Supprime erreurs
commande &> /dev/null                                # Supprime tout
commande > >(tee output.txt)                         # Affiche et sauvegarde

# === Redirection entrée ===
commande < input.txt                                 # Stdin depuis fichier
commande << EOF                                      # Here document
ligne 1
ligne 2
EOF
commande <<< "string"                                # Here string

# === Pipes (|) ===
commande1 | commande2                                # Output cmd1 -> input cmd2
cat fichier.txt | grep "pattern"
ls -l | wc -l                                        # Compte fichiers
ps aux | grep python | wc -l                         # Compte processus Python
cat fichier.txt | sort | uniq                        # Tri et unique
history | tail -20                                   # 20 dernières commandes
find . -type f | wc -l                               # Compte fichiers

# === Tee (duplique output) ===
commande | tee output.txt                            # Affiche et sauvegarde
commande | tee -a output.txt                         # Append
commande | tee file1.txt file2.txt                   # Plusieurs fichiers
commande 2>&1 | tee output.txt                       # Avec stderr

# === Xargs (arguments) ===
find . -name "*.txt" | xargs rm                      # Passe résultats comme args
echo "file1 file2" | xargs cat                       # Cat plusieurs fichiers
find . -name "*.log" | xargs grep "error"            # Grep dans fichiers trouvés
find . -name "*.txt" | xargs -I {} mv {} {}.bak      # Remplace placeholder
find . -name "*.txt" | xargs -n 1 wc -l              # Un argument à la fois
find . -type f | xargs -P 4 gzip                     # Parallèle (4 processus)
cat urls.txt | xargs -n 1 curl                       # Une URL à la fois
echo "a b c" | xargs -n 1                            # Nouvelle ligne par arg


[OK] PERMISSIONS & PROPRIÉTÉ


# === Chmod (permissions) ===
chmod 755 script.sh                                  # rwxr-xr-x
chmod 644 fichier.txt                                # rw-r--r--
chmod 600 secret.txt                                 # rw-------
chmod 777 fichier.txt                                # rwxrwxrwx ([ATTENTION] dangereux)
chmod +x script.sh                                   # Ajoute exécution
chmod -x script.sh                                   # Enlève exécution
chmod u+x script.sh                                  # User execute
chmod g+w fichier.txt                                # Group write
chmod o-r fichier.txt                                # Others no read
chmod a+r fichier.txt                                # All read
chmod u=rw,g=r,o= fichier.txt                        # Explicite
chmod -R 755 dossier/                                # Récursif
chmod --reference=ref.txt fichier.txt                # Copie permissions

# Codes numériques:
# 4 = read (r)
# 2 = write (w)
# 1 = execute (x)
# 755 = rwxr-xr-x (4+2+1, 4+1, 4+1)
# 644 = rw-r--r-- (4+2, 4, 4)
# 600 = rw------- (4+2, 0, 0)

# Symboles:
# u = user (propriétaire)
# g = group
# o = others
# a = all

# === Chown (propriétaire) ===
chown user fichier.txt                               # Change propriétaire
chown user:group fichier.txt                         # User et groupe
chown :group fichier.txt                             # Seulement groupe
chown -R user:group dossier/                         # Récursif
sudo chown root:root fichier.txt                     # Root (besoin sudo)

# === Chgrp (groupe) ===
chgrp group fichier.txt                              # Change groupe
chgrp -R group dossier/                              # Récursif

# === Umask ===
umask                                                # Voir umask actuel
umask 022                                            # Set umask (défaut 644 fichiers)
umask 077                                            # Restrictif (600 fichiers)

# === Lister permissions ===
ls -l fichier.txt                                    # Format long
stat fichier.txt                                     # Détails complets
getfacl fichier.txt                                  # ACL (si supporté)


[OK] PROCESSUS


# === Ps (processus) ===
ps                                                   # Processus shell courant
ps aux                                               # Tous processus (BSD)
ps -ef                                               # Tous processus (System V)
ps -u username                                       # Par utilisateur
ps -p 1234                                           # Par PID
ps aux | grep python                                 # Filtre Python
ps aux --sort=-mem                                   # Tri par mémoire
ps aux --sort=-pcpu                                  # Tri par CPU
ps -eo pid,ppid,cmd,%mem,%cpu                        # Colonnes custom
ps -ejH                                              # Arborescence
ps -eLf                                              # Avec threads

# === Top (temps réel) ===
top                                                  # Moniteur temps réel
# Navigation top:
# q      : Quitter
# k      : Kill processus
# r      : Renice
# u      : Filtre utilisateur
# M      : Tri par mémoire
# P      : Tri par CPU
# 1      : Tous CPUs
# h      : Aide

top -u username                                      # Par utilisateur
top -p 1234                                          # PID spécifique
top -n 1                                             # Une itération
top -b -n 1 > top.txt                                # Batch mode

# === Htop (meilleur que top) ===
htop                                                 # Interface interactive
# Installation: sudo apt install htop

# === Kill (terminer processus) ===
kill 1234                                            # Kill PID (SIGTERM)
kill -9 1234                                         # Force kill (SIGKILL)
kill -15 1234                                        # SIGTERM (graceful)
kill -KILL 1234                                      # SIGKILL (force)
kill -HUP 1234                                       # SIGHUP (reload)
kill -STOP 1234                                      # SIGSTOP (pause)
kill -CONT 1234                                      # SIGCONT (reprend)
killall python                                       # Kill par nom
killall -9 python                                    # Force
pkill python                                         # Comme killall
pkill -u username                                    # Par utilisateur
pkill -f "script.py"                                 # Par commande complète

# === Pgrep (trouve PID) ===
pgrep python                                         # PID processus Python
pgrep -u username                                    # Par utilisateur
pgrep -l python                                      # Avec nom
pgrep -a python                                      # Avec commande complète

# === Jobs (tâches background) ===
command &                                            # Lance en background
jobs                                                 # Liste jobs
jobs -l                                              # Avec PID
fg                                                   # Ramène au foreground
fg %1                                                # Job spécifique
bg                                                   # Reprend en background
bg %1                                                # Job spécifique
Ctrl+Z                                               # Suspend job
disown                                               # Détache job du shell
disown %1                                            # Job spécifique
nohup command &                                      # Résiste déconnexion

# === Nice & Renice (priorité) ===
nice -n 10 command                                   # Lance avec priorité basse
nice -n -10 command                                  # Priorité haute (sudo)
renice -n 5 -p 1234                                  # Change priorité
renice -n 5 -u username                              # Par utilisateur

# === Autres ===
pstree                                               # Arborescence processus
pstree -p                                            # Avec PID
pidof python                                         # PID par nom
lsof                                                 # Fichiers ouverts
lsof -i :8080                                        # Processus sur port
lsof -u username                                     # Par utilisateur
fuser 8080/tcp                                       # PID utilisant port


[OK] RÉSEAU


# === Ping ===
ping google.com                                      # Ping infini
ping -c 4 google.com                                 # 4 pings
ping -c 10 -i 2 google.com                           # Intervalle 2s
ping -s 1000 google.com                              # Taille paquet 1000 bytes
ping -W 1 google.com                                 # Timeout 1s

# === Curl ===
curl https://example.com                             # GET request
curl -o fichier.html https://example.com             # Sauvegarder
curl -O https://example.com/file.zip                 # Nom original
curl -L https://example.com                          # Suit redirections
curl -I https://example.com                          # Headers seulement
curl -v https://example.com                          # Verbose
curl -X POST https://api.example.com                 # POST request
curl -X POST -d "key=value" https://api.com          # POST avec données
curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' https://api.com
curl -u user:pass https://example.com                # Authentification
curl -H "Authorization: Bearer token" https://api.com
curl -b cookies.txt https://example.com              # Envoie cookies
curl -c cookies.txt https://example.com              # Sauvegarde cookies
curl --data-binary @file.json https://api.com        # Upload fichier
curl -F "file=@image.jpg" https://api.com/upload     # Upload multipart
curl -x proxy:8080 https://example.com               # Via proxy
curl --limit-rate 100k https://example.com/file.zip  # Limite bande passante
curl -C - -O https://example.com/bigfile.zip         # Reprend téléchargement
curl -w "@curl-format.txt" https://example.com       # Format output custom
curl -s https://example.com                          # Silent
curl -S https://example.com                          # Montre erreurs en silent
curl --compressed https://example.com                # Accept compression
curl -k https://example.com                          # Ignore SSL errors

# === Wget ===
wget https://example.com/file.zip                    # Télécharge
wget -O custom-name.zip https://example.com/file.zip # Nom custom
wget -c https://example.com/file.zip                 # Reprend téléchargement
wget -b https://example.com/file.zip                 # Background
wget -i urls.txt                                     # Liste URLs
wget -r https://example.com                          # Récursif (mirror site)
wget -r -np -k https://example.com                   # Mirror propre
wget --limit-rate=200k https://example.com/file.zip  # Limite vitesse
wget --spider https://example.com                    # Vérifie sans télécharger
wget --user=user --password=pass https://example.com # Authentification
wget --no-check-certificate https://example.com      # Ignore SSL

# === Netstat ===
netstat -tuln                                        # Ports en écoute
netstat -tulnp                                       # Avec PID/nom programme
netstat -an                                          # Toutes connexions
netstat -r                                           # Table routage
netstat -s                                           # Statistiques
netstat -i                                           # Interfaces réseau

# === Ss (remplace netstat) ===
ss -tuln                                             # Ports en écoute
ss -tulnp                                            # Avec processus
ss -s                                                # Statistiques
ss -ta                                               # TCP toutes
ss -ua                                               # UDP toutes
ss -lt                                               # TCP listening
ss -o state established                              # Connexions établies
ss -o state time-wait                                # TIME_WAIT
ss dst 192.168.1.1                                   # Destination spécifique
ss sport = :22                                       # Port source 22

# === Ip (remplace ifconfig) ===
ip addr                                              # Adresses IP
ip a                                                 # Alias court
ip addr show eth0                                    # Interface spécifique
ip link                                              # Interfaces réseau
ip link show                                         # Détails interfaces
ip link set eth0 up                                  # Active interface
ip link set eth0 down                                # Désactive
ip route                                             # Table routage
ip route show                                        # Alias
ip route add default via 192.168.1.1                 # Route par défaut
ip route del default                                 # Supprime route
ip neigh                                             # Table ARP
ip -s link                                           # Statistiques interfaces

# === Ifconfig (ancien) ===
ifconfig                                             # Toutes interfaces
ifconfig eth0                                        # Interface spécifique
ifconfig eth0 up                                     # Active
ifconfig eth0 down                                   # Désactive
ifconfig eth0 192.168.1.100                          # Attribue IP

# === Nc (netcat) ===
nc -l 8080                                           # Écoute port 8080
nc localhost 8080                                    # Connecte à port
nc -zv example.com 80                                # Test port ouvert
nc -zv example.com 20-80                             # Scan ports 20-80
echo "GET / HTTP/1.0" | nc example.com 80            # Requête HTTP
nc -l 8080 > fichier                                 # Reçoit fichier
nc example.com 8080 < fichier                        # Envoie fichier

# === Nslookup ===
nslookup example.com                                 # Résolution DNS
nslookup example.com 8.8.8.8                         # Serveur DNS spécifique

# === Dig (meilleur que nslookup) ===
dig example.com                                      # Query DNS
dig example.com +short                               # Réponse courte
dig example.com A                                    # Record A
dig example.com MX                                   # Record MX (mail)
dig example.com NS                                   # Record NS (nameservers)
dig example.com TXT                                  # Record TXT
dig @8.8.8.8 example.com                             # Serveur DNS spécifique
dig -x 8.8.8.8                                       # Reverse DNS
dig example.com +trace                               # Trace complet

# === Host ===
host example.com                                     # Résolution simple
host -t MX example.com                               # Record MX
host -t A example.com                                # Record A

# === Traceroute ===
traceroute example.com                               # Trace route
traceroute -n example.com                            # Sans résolution DNS
traceroute -m 15 example.com                         # Max 15 hops
tracepath example.com                                # Alternative

# === Telnet ===
telnet example.com 80                                # Connexion port 80
telnet localhost 22                                  # Test SSH local

# === Scp (secure copy) ===
scp fichier.txt user@host:/path/                     # Copy vers remote
scp user@host:/path/fichier.txt .                    # Copy depuis remote
scp -r dossier/ user@host:/path/                     # Récursif
scp -P 2222 fichier.txt user@host:/path/             # Port custom
scp -i key.pem fichier.txt user@host:/path/          # Clé SSH spécifique

# === Rsync ===
rsync -avz source/ dest/                             # Sync local
rsync -avz source/ user@host:/dest/                  # Sync remote
rsync -avz --delete source/ dest/                    # Supprime dans dest
rsync -avz --exclude='*.log' source/ dest/           # Exclut pattern
rsync -avzP source/ dest/                            # Avec progression
rsync -avz --dry-run source/ dest/                   # Simulation
rsync -avz -e "ssh -p 2222" source/ user@host:/dest/ # Port SSH custom

# === Ssh ===
ssh user@host                                        # Connexion SSH
ssh -p 2222 user@host                                # Port custom
ssh -i key.pem user@host                             # Clé privée
ssh user@host "commande"                             # Exécute commande
ssh -L 8080:localhost:80 user@host                   # Port forwarding local
ssh -R 8080:localhost:80 user@host                   # Port forwarding remote
ssh -D 8080 user@host                                # SOCKS proxy
ssh -X user@host                                     # X11 forwarding
ssh-keygen                                           # Génère paire clés
ssh-keygen -t rsa -b 4096                            # RSA 4096 bits
ssh-keygen -t ed25519                                # Ed25519 (moderne)
ssh-copy-id user@host                                # Copie clé publique
ssh-add ~/.ssh/id_rsa                                # Ajoute clé à agent

# === Firewall (UFW - Ubuntu) ===
sudo ufw status                                      # Statut firewall
sudo ufw enable                                      # Active
sudo ufw disable                                     # Désactive
sudo ufw allow 22                                    # Autorise port
sudo ufw allow ssh                                   # Autorise SSH
sudo ufw allow 80/tcp                                # TCP port 80
sudo ufw allow from 192.168.1.0/24                   # Sous-réseau
sudo ufw deny 23                                     # Bloque port
sudo ufw delete allow 80                             # Supprime règle


[OK] COMPRESSION & ARCHIVES


# === Tar ===
tar -cvf archive.tar fichiers/                       # Crée archive
tar -xvf archive.tar                                 # Extrait
tar -tvf archive.tar                                 # Liste contenu
tar -cvzf archive.tar.gz fichiers/                   # Gzip compression
tar -xvzf archive.tar.gz                             # Extrait gzip
tar -cvjf archive.tar.bz2 fichiers/                  # Bzip2 compression
tar -xvjf archive.tar.bz2                            # Extrait bzip2
tar -cvJf archive.tar.xz fichiers/                   # Xz compression
tar -xvJf archive.tar.xz                             # Extrait xz
tar -xvf archive.tar -C /destination/                # Extrait dans dossier
tar -xvf archive.tar fichier.txt                     # Extrait fichier spécifique
tar -cvf archive.tar --exclude='*.log' dossier/      # Exclut pattern
tar -rvf archive.tar nouveau-fichier.txt             # Ajoute à archive
tar -uvf archive.tar fichiers/                       # Update (si plus récent)
tar -dvf archive.tar                                 # Compare avec filesystem

# Options:
# c : Create
# x : Extract
# t : List
# v : Verbose
# f : File
# z : Gzip
# j : Bzip2
# J : Xz

# === Gzip ===
gzip fichier.txt                                     # Compresse (remplace fichier)
gzip -k fichier.txt                                  # Garde original
gzip -9 fichier.txt                                  # Compression max
gzip -1 fichier.txt                                  # Compression rapide
gzip -d fichier.txt.gz                               # Décompresse
gunzip fichier.txt.gz                                # Alias
gzip -c fichier.txt > fichier.txt.gz                 # Vers stdout
gzip -r dossier/                                     # Récursif
gzip -l fichier.txt.gz                               # Info compression

# === Bzip2 ===
bzip2 fichier.txt                                    # Compresse
bzip2 -k fichier.txt                                 # Garde original
bzip2 -9 fichier.txt                                 # Compression max
bzip2 -d fichier.txt.bz2                             # Décompresse
bunzip2 fichier.txt.bz2                              # Alias

# === Xz ===
xz fichier.txt                                       # Compresse
xz -k fichier.txt                                    # Garde original
xz -9 fichier.txt                                    # Compression max
xz -d fichier.txt.xz                                 # Décompresse
unxz fichier.txt.xz                                  # Alias

# === Zip ===
zip archive.zip fichier.txt                          # Crée zip
zip -r archive.zip dossier/                          # Récursif
zip -e archive.zip fichier.txt                       # Avec mot de passe
zip -9 archive.zip fichier.txt                       # Compression max
zip -u archive.zip nouveau.txt                       # Update
zip -d archive.zip fichier.txt                       # Supprime de archive
zip -T archive.zip                                   # Test intégrité
unzip archive.zip                                    # Extrait
unzip -l archive.zip                                 # Liste contenu
unzip -t archive.zip                                 # Test
unzip archive.zip -d /destination/                   # Vers dossier
unzip -q archive.zip                                 # Quiet

# === Rar (si installé) ===
rar a archive.rar fichiers/                          # Crée rar
rar x archive.rar                                    # Extrait
rar l archive.rar                                    # Liste
rar t archive.rar                                    # Test
unrar x archive.rar                                  # Alternative extraction

# === 7z ===
7z a archive.7z fichiers/                            # Crée 7z
7z x archive.7z                                      # Extrait
7z l archive.7z                                      # Liste
7z t archive.7z                                      # Test
7z a -p archive.7z fichier.txt                       # Avec mot de passe


[OK] SYSTÈME & INFORMATIONS


# === Informations système ===
uname -a                                             # Info système complète
uname -s                                             # Nom système (Linux)
uname -n                                             # Nom hôte
uname -r                                             # Version kernel
uname -m                                             # Architecture (x86_64)
hostname                                             # Nom machine
hostname -I                                          # Adresses IP
hostnamectl                                          # Info détaillée (systemd)

# === Distribution ===
cat /etc/os-release                                  # Info distribution
lsb_release -a                                       # LSB info
cat /etc/issue                                       # Version courte

# === Uptime ===
uptime                                               # Temps fonctionnement
uptime -p                                            # Format lisible
uptime -s                                            # Date démarrage

# === Who & W ===
who                                                  # Utilisateurs connectés
who -b                                               # Dernier boot
w                                                    # Utilisateurs + activité
whoami                                               # Utilisateur actuel
id                                                   # UID, GID, groupes
id username                                          # Pour utilisateur spécifique
groups                                               # Groupes de l'utilisateur
groups username                                      # Groupes d'un utilisateur

# === Date & Time ===
date                                                 # Date et heure
date +"%Y-%m-%d"                                     # Format custom
date +"%Y-%m-%d %H:%M:%S"                            # Date complète
date +"%s"                                           # Timestamp Unix
date -d "2024-01-01"                                 # Parse date
date -d "now + 1 day"                                # Date relative
date -d "yesterday"                                  # Hier
date -d "@1234567890"                                # Depuis timestamp
timedatectl                                          # Info temps système
timedatectl set-time "2024-01-01 12:00:00"           # Change date/heure
timedatectl set-timezone Europe/Paris                # Change timezone
timedatectl list-timezones                           # Liste timezones

# === Calendrier ===
cal                                                  # Mois actuel
cal 2024                                             # Année complète
cal 12 2024                                          # Décembre 2024
ncal                                                 # Vertical

# === Hardware ===
lscpu                                                # Info CPU
lscpu | grep "Model name"                            # Nom CPU
nproc                                                # Nombre CPUs
cat /proc/cpuinfo                                    # Info CPU détaillée
lsmem                                                # Info mémoire
free                                                 # Mémoire libre
free -h                                              # Human readable
free -m                                              # En Mo
free -g                                              # En Go
cat /proc/meminfo                                    # Mémoire détaillée
lsblk                                                # Disques et partitions
lsblk -f                                             # Avec filesystems
lsblk -a                                             # Tous devices
blkid                                                # UUID et labels
fdisk -l                                             # Partitions (root)
df                                                   # Espace disque
df -h                                                # Human readable
df -i                                                # Inodes
df -T                                                # Avec type filesystem
du                                                   # Utilisation disque
du -h                                                # Human readable
du -sh dossier/                                      # Résumé dossier
du -sh *                                             # Tous items courants
du -h --max-depth=1                                  # Profondeur 1
du -ah | sort -h                                     # Tri par taille
ncdu                                                 # TUI disk usage (installé séparément)

# === PCI & USB ===
lspci                                                # Devices PCI
lspci -v                                             # Verbose
lspci | grep VGA                                     # Carte graphique
lsusb                                                # Devices USB
lsusb -v                                             # Verbose

# === DMI (hardware info) ===
sudo dmidecode                                       # Info hardware complète
sudo dmidecode -t system                             # Info système
sudo dmidecode -t bios                               # Info BIOS
sudo dmidecode -t processor                          # Info CPU
sudo dmidecode -t memory                             # Info RAM

# === Kernel ===
dmesg                                                # Messages kernel
dmesg | grep -i error                                # Erreurs kernel
dmesg | tail -50                                     # 50 derniers messages
dmesg -T                                             # Avec timestamps lisibles
dmesg -l err,warn                                    # Erreurs et warnings seulement
journalctl -k                                        # Logs kernel (systemd)

# === Modules kernel ===
lsmod                                                # Modules chargés
lsmod | grep module_name                             # Cherche module
modinfo module_name                                  # Info module
sudo modprobe module_name                            # Charge module
sudo modprobe -r module_name                         # Décharge module

# === Services (systemd) ===
systemctl status service_name                        # Statut service
systemctl start service_name                         # Démarre
systemctl stop service_name                          # Arrête
systemctl restart service_name                       # Redémarre
systemctl reload service_name                        # Reload config
systemctl enable service_name                        # Active au boot
systemctl disable service_name                       # Désactive au boot
systemctl is-active service_name                     # Vérifie si actif
systemctl is-enabled service_name                    # Vérifie si enabled
systemctl list-units --type=service                  # Liste services
systemctl list-units --failed                        # Services échoués
journalctl -u service_name                           # Logs service
journalctl -u service_name -f                        # Follow logs
journalctl -u service_name --since today             # Logs aujourd'hui
journalctl -u service_name --since "1 hour ago"      # Dernière heure

# === Runlevel / Target ===
runlevel                                             # Runlevel actuel
who -r                                               # Runlevel
systemctl get-default                                # Target par défaut
systemctl set-default multi-user.target              # Change target défaut
systemctl isolate rescue.target                      # Change vers rescue mode

# === Shutdown & Reboot ===
shutdown now                                         # Éteint immédiatement
shutdown -h now                                      # Halt
shutdown -r now                                      # Reboot
shutdown -h +10                                      # Éteint dans 10 min
shutdown -h 23:00                                    # Éteint à 23h
shutdown -c                                          # Annule shutdown
reboot                                               # Redémarre
reboot -f                                            # Force reboot
halt                                                 # Arrête système
poweroff                                             # Éteint


[OK] UTILISATEURS & GROUPES


# === Utilisateurs ===
useradd username                                     # Crée utilisateur
useradd -m username                                  # Avec home directory
useradd -m -s /bin/bash username                     # Avec shell
useradd -m -G group1,group2 username                 # Avec groupes
userdel username                                     # Supprime utilisateur
userdel -r username                                  # Supprime avec home
usermod -l nouveau ancien                            # Renomme
usermod -aG sudo username                            # Ajoute au groupe sudo
usermod -s /bin/zsh username                         # Change shell
passwd username                                      # Change mot de passe
passwd -l username                                   # Lock utilisateur
passwd -u username                                   # Unlock
passwd -S username                                   # Statut password
chage -l username                                    # Info expiration password
chage -M 90 username                                 # Password expire 90j
su - username                                        # Switch user
sudo -u username commande                            # Exécute comme user
sudo -i                                              # Shell root
sudo -s                                              # Shell avec env user

# === Groupes ===
groupadd groupname                                   # Crée groupe
groupdel groupname                                   # Supprime groupe
groupmod -n nouveau ancien                           # Renomme groupe
gpasswd -a username groupname                        # Ajoute user au groupe
gpasswd -d username groupname                        # Retire user du groupe
gpasswd -A username groupname                        # Admin du groupe
newgrp groupname                                     # Change groupe primaire

# === Fichiers utilisateurs ===
cat /etc/passwd                                      # Liste utilisateurs
cat /etc/group                                       # Liste groupes
cat /etc/shadow                                      # Passwords (root only)
getent passwd                                        # Tous users (inc. LDAP)
getent group                                         # Tous groupes
lastlog                                              # Dernières connexions
last                                                 # Historique connexions
last -n 10                                           # 10 dernières
last username                                        # Pour utilisateur
lastb                                                # Tentatives échouées


[OK] VARIABLES & ENVIRONNEMENT


# === Variables ===
var="valeur"                                         # Définit variable
echo $var                                            # Affiche variable
echo ${var}                                          # Alternative
unset var                                            # Supprime variable
export VAR="valeur"                                  # Variable d'environnement
export PATH=$PATH:/nouveau/chemin                    # Ajoute au PATH
readonly VAR="constante"                             # Variable lecture seule

# === Variables d'environnement ===
env                                                  # Liste toutes
printenv                                             # Liste toutes
printenv PATH                                        # Variable spécifique
echo $PATH                                           # Affiche PATH
echo $HOME                                           # Home directory
echo $USER                                           # Username
echo $SHELL                                          # Shell actuel
echo $PWD                                            # Directory actuel
echo $OLDPWD                                         # Directory précédent
echo $HOSTNAME                                       # Nom hôte
echo $LANG                                           # Locale
echo $EDITOR                                         # Éditeur par défaut
echo $TERM                                           # Type terminal

# Variables spéciales:
# $0    : Nom du script
# $1-$9 : Arguments 1 à 9
# $#    : Nombre d'arguments
# $@    : Tous arguments
# $*    : Tous arguments (string)
# $?    : Exit status dernière commande
# $    : PID du shell
# $!    : PID dernier processus background

# === Substitution ===
echo "Utilisateur: $USER"                            # Substitution simple
echo "1+1 = $((1+1))"                                # Arithmétique
echo "Fichiers: $(ls)"                               # Commande
echo "Fichiers: `ls`"                                # Alternative (ancien)
echo "Longueur: ${#var}"                             # Longueur string
echo "${var:-defaut}"                                # Valeur par défaut
echo "${var:=defaut}"                                # Assigne si vide
echo "${var:?error}"                                 # Erreur si vide
echo "${var:+alternative}"                           # Alternative si non-vide
echo "${var:0:5}"                                    # Substring (pos, len)
echo "${var#pattern}"                                # Supprime début
echo "${var%pattern}"                                # Supprime fin
echo "${var/old/new}"                                # Remplace 1ère occurrence
echo "${var//old/new}"                               # Remplace toutes
echo "${var^}"                                       # 1er char majuscule
echo "${var^^}"                                      # Tout majuscules
echo "${var,}"                                       # 1er char minuscule
echo "${var,,}"                                      # Tout minuscules

# === Arrays ===
array=(un deux trois)                                # Crée array
echo ${array[0]}                                     # 1er élément
echo ${array[@]}                                     # Tous éléments
echo ${#array[@]}                                    # Nombre éléments
array[3]="quatre"                                    # Ajoute élément
unset array[1]                                       # Supprime élément
array+=(cinq six)                                    # Append


[OK] SCRIPTING BASH


# === Shebang ===
#!/bin/bash                                          # Shebang (1ère ligne)
#!/usr/bin/env bash                                  # Portable
#!/bin/sh                                            # Shell POSIX

# === Exécution ===
bash script.sh                                       # Exécute avec bash
./script.sh                                          # Exécute directement (besoin chmod +x)
sh script.sh                                         # Exécute avec sh
source script.sh                                     # Exécute dans shell courant
. script.sh                                          # Alias de source

# === Commentaires ===
# Ceci est un commentaire
: '
Ceci est un
commentaire multi-ligne
'

# === Echo & Printf ===
echo "Hello World"                                   # Affiche texte
echo -n "Sans newline"                               # Sans nouvelle ligne
echo -e "Avec\ntab\tet\nnewline"                     # Interprète échappements
printf "Format: %s\n" "texte"                        # Printf style
printf "%d + %d = %d\n" 1 2 3                        # Avec nombres
printf "%-10s %5d\n" "Item" 42                       # Alignement

# === Read (input) ===
read var                                             # Lit input
read -p "Nom: " nom                                  # Avec prompt
read -s password                                     # Silent (password)
read -n 1 char                                       # 1 caractère
read -t 5 var                                        # Timeout 5s
read -a array                                        # Dans array
IFS=',' read -ra array <<< "a,b,c"                   # Split par délimiteur

# === Conditions (if) ===
if [ condition ]; then
    commandes
fi

if [ condition ]; then
    commandes
else
    autres
fi

if [ condition1 ]; then
    commandes1
elif [ condition2 ]; then
    commandes2
else
    commandes3
fi

# Tests fichiers:
# -e fichier  : Existe
# -f fichier  : Fichier régulier
# -d fichier  : Dossier
# -L fichier  : Lien symbolique
# -r fichier  : Lisible
# -w fichier  : Writable
# -x fichier  : Exécutable
# -s fichier  : Non vide
# -n string   : String non-vide
# -z string   : String vide

# Tests comparaisons:
# -eq  : Égal
# -ne  : Différent
# -lt  : Plus petit
# -le  : Plus petit ou égal
# -gt  : Plus grand
# -ge  : Plus grand ou égal

# Exemples:
if [ -f fichier.txt ]; then
    echo "Fichier existe"
fi

if [ $a -eq $b ]; then
    echo "Égaux"
fi

if [ "$str1" = "$str2" ]; then
    echo "Strings égales"
fi

# Tests avancés [[ ]]:
if [[ $var =~ ^[0-9]+$ ]]; then
    echo "Numérique"
fi

if [[ "$str" == *"substring"* ]]; then
    echo "Contient substring"
fi

# Opérateurs logiques:
if [ condition1 ] && [ condition2 ]; then
    echo "ET"
fi

if [ condition1 ] || [ condition2 ]; then
    echo "OU"
fi

if [ ! condition ]; then
    echo "NON"
fi

# === Case ===
case $var in
    pattern1)
        commandes1
        ;;
    pattern2|pattern3)
        commandes2
        ;;
    *)
        defaut
        ;;
esac

# Exemple:
case $option in
    start)
        echo "Démarrage"
        ;;
    stop)
        echo "Arrêt"
        ;;
    restart)
        echo "Redémarrage"
        ;;
    *)
        echo "Option inconnue"
        ;;
esac

# === Boucles (for) ===
for i in 1 2 3 4 5; do
    echo $i
done

for file in *.txt; do
    echo "Fichier: $file"
done

for i in {1..10}; do
    echo $i
done

for i in {1..100..10}; do  # 1, 11, 21, ...
    echo $i
done

for ((i=0; i<10; i++)); do
    echo $i
done

# === Boucles (while) ===
while [ condition ]; do
    commandes
done

i=0
while [ $i -lt 10 ]; do
    echo $i
    ((i++))
done

# === Boucles (until) ===
until [ condition ]; do
    commandes
done

# === Select (menu) ===
select option in "Option 1" "Option 2" "Quitter"; do
    case $option in
        "Option 1")
            echo "Option 1 choisie"
            ;;
        "Option 2")
            echo "Option 2 choisie"
            ;;
        "Quitter")
            break
            ;;
        *)
            echo "Option invalide"
            ;;
    esac
done

# === Fonctions ===
function nom_fonction {
    commandes
}

# Alternative:
nom_fonction() {
    commandes
}

# Avec paramètres:
fonction() {
    echo "Param 1: $1"
    echo "Param 2: $2"
    echo "Tous: $@"
    echo "Nombre: $#"
}
fonction arg1 arg2

# Retour de valeur:
add() {
    echo $(($1 + $2))
}
resultat=$(add 5 3)

# Variables locales:
fonction() {
    local var="locale"
    echo $var
}

# === Arithmétique ===
((i++))                                              # Incrémente
((i--))                                              # Décrémente
((i += 5))                                           # Ajoute 5
result=$((5 + 3))                                    # Addition
result=$((10 - 2))                                   # Soustraction
result=$((4 * 3))                                    # Multiplication
result=$((10 / 3))                                   # Division (entière)
result=$((10 % 3))                                   # Modulo
result=$((2 ** 3))                                   # Puissance

# Avec let:
let "result = 5 + 3"
let "i++"

# Avec expr (ancien):
result=$(expr 5 + 3)

# Virgule flottante avec bc:
result=$(echo "scale=2; 10 / 3" | bc)

# === Tableaux associatifs ===
declare -A assoc
assoc[key1]="value1"
assoc[key2]="value2"
echo ${assoc[key1]}
echo ${!assoc[@]}                                    # Toutes les clés
echo ${assoc[@]}                                     # Toutes les valeurs

# === Gestion erreurs ===
set -e                                               # Exit si erreur
set -u                                               # Exit si variable non-définie
set -o pipefail                                      # Exit si erreur dans pipe
set -x                                               # Debug (affiche commandes)

# Trap (capture signaux):
trap "echo 'Interrupted'; exit" INT TERM
trap "rm -f /tmp/tempfile" EXIT

# === Exit status ===
command
if [ $? -eq 0 ]; then
    echo "Succès"
else
    echo "Erreur"
fi

# OU:
if command; then
    echo "Succès"
fi

# === Options getopts ===
while getopts ":a:b:c" opt; do
    case $opt in
        a)
            echo "Option -a: $OPTARG"
            ;;
        b)
            echo "Option -b: $OPTARG"
            ;;
        c)
            echo "Option -c"
            ;;
        \?)
            echo "Option invalide: -$OPTARG"
            exit 1
            ;;
        :)
            echo "Option -$OPTARG nécessite argument"
            exit 1
            ;;
    esac
done

# === Here Document ===
cat << EOF
Texte multi-ligne
Variable: $VAR
Autre ligne
EOF

# Sans expansion:
cat << 'EOF'
Variable non-expandée: $VAR
EOF

# === Here String ===
grep "pattern" <<< "texte à chercher"

# === Redirection avancée ===
# Redirection stderr vers stdout:
command 2>&1

# Swap stdout et stderr:
command 3>&1 1>&2 2>&3

# Redirection vers multiple destinations:
command | tee file1.txt file2.txt

# === Process substitution ===
diff <(ls dir1) <(ls dir2)                           # Compare outputs
while read line; do echo $line; done < <(command)

# === Couleurs ===
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

echo -e "${RED}Texte rouge${NC}"
echo -e "${GREEN}Texte vert${NC}"

# Codes couleurs:
# 30: Noir, 31: Rouge, 32: Vert, 33: Jaune
# 34: Bleu, 35: Magenta, 36: Cyan, 37: Blanc
# Ajouter 10 pour background (40-47)
# 0: Normal, 1: Bold, 4: Underline, 5: Blink


[OK] HISTORIQUE COMMANDES


# === History ===
history                                              # Tout l'historique
history 20                                           # 20 dernières
history | grep "pattern"                             # Cherche dans historique
!!                                                   # Répète dernière commande
!n                                                   # Exécute commande n
!-2                                                  # Avant-dernière commande
!string                                              # Dernière commande commençant par string
!?string                                             # Dernière contenant string
^old^new                                             # Remplace old par new dans dernière
!$                                                   # Dernier argument dernière commande
!*                                                   # Tous arguments dernière commande
!:1                                                  # 1er argument dernière commande
!:2                                                  # 2ème argument
Ctrl+R                                               # Recherche interactive historique
Ctrl+G                                               # Annule recherche
Ctrl+P                                               # Commande précédente
Ctrl+N                                               # Commande suivante
Alt+.                                                # Dernier argument (répétable)
Alt+<                                                # Début historique
Alt+>                                                # Fin historique

# === Gestion historique ===
history -c                                           # Efface historique session
history -w                                           # Sauvegarde historique
history -r                                           # Recharge historique
history -d n                                         # Supprime ligne n
fc -l                                                # Liste historique
fc -e vim 10                                         # Édite commande 10 avec vim
HISTSIZE=1000                                        # Taille historique en mémoire
HISTFILESIZE=2000                                    # Taille fichier historique
HISTCONTROL=ignoredups                               # Ignore doublons
HISTCONTROL=ignorespace                              # Ignore commandes avec espace initial
HISTCONTROL=ignoreboth                               # Les deux
HISTIGNORE="ls:cd:exit"                              # Ignore ces commandes
HISTTIMEFORMAT="%F %T "                              # Format timestamps

# Fichier historique: ~/.bash_history


[OK] RACCOURCIS CLAVIER BASH


# === Navigation ligne ===
Ctrl+A                                               # Début de ligne
Ctrl+E                                               # Fin de ligne
Alt+F                                                # Mot suivant
Alt+B                                                # Mot précédent
Ctrl+XX                                              # Toggle début/position

# === Édition ===
Ctrl+U                                               # Efface jusqu'au début
Ctrl+K                                               # Efface jusqu'à la fin
Ctrl+W                                               # Efface mot précédent
Alt+D                                                # Efface mot suivant
Ctrl+Y                                               # Colle (yank)
Ctrl+T                                               # Transpose 2 caractères
Alt+T                                                # Transpose 2 mots
Alt+U                                                # Mot en majuscules
Alt+L                                                # Mot en minuscules
Alt+C                                                # Capitalize mot

# === Contrôle ===
Ctrl+C                                               # Interrompt commande (SIGINT)
Ctrl+D                                               # EOF / Logout
Ctrl+Z                                               # Suspend processus (SIGTSTP)
Ctrl+L                                               # Clear écran
Ctrl+S                                               # Stop output (freeze)
Ctrl+Q                                               # Resume output

# === Historique ===
Ctrl+R                                               # Recherche historique
Ctrl+G                                               # Annule recherche
Ctrl+P                                               # Commande précédente (^)
Ctrl+N                                               # Commande suivante (v)
Alt+<                                                # Premier historique
Alt+>                                                # Dernier historique

# === Complétion ===
Tab                                                  # Complétion
Tab Tab                                              # Liste complétions
Alt+?                                                # Liste complétions
Alt+*                                                # Insère toutes complétions
Ctrl+X Ctrl+E                                        # Édite ligne dans $EDITOR


[OK] JOB CONTROL


# === Background & Foreground ===
command &                                            # Lance en background
jobs                                                 # Liste jobs
jobs -l                                              # Avec PID
jobs -r                                              # Running seulement
jobs -s                                              # Stopped seulement
fg                                                   # Ramène dernier job au foreground
fg %1                                                # Job 1 au foreground
bg                                                   # Reprend dernier job en background
bg %1                                                # Job 1 en background
Ctrl+Z                                               # Suspend job courant
kill %1                                              # Kill job 1
kill -9 %1                                           # Force kill job 1
disown                                               # Détache job du shell
disown %1                                            # Détache job 1
disown -a                                            # Détache tous jobs
disown -h %1                                         # Job 1 ignore SIGHUP

# === Nohup ===
nohup command &                                      # Résiste déconnexion
nohup command > output.log 2>&1 &                    # Avec log

# === Screen ===
screen                                               # Nouvelle session
screen -S session_name                               # Session nommée
Ctrl+A D                                             # Détache session
screen -ls                                           # Liste sessions
screen -r                                            # Rattache dernière
screen -r session_name                               # Rattache session nommée
screen -X -S session_name quit                       # Tue session
# Dans screen:
Ctrl+A C                                             # Nouvelle fenêtre
Ctrl+A N                                             # Fenêtre suivante
Ctrl+A P                                             # Fenêtre précédente
Ctrl+A "                                             # Liste fenêtres
Ctrl+A K                                             # Tue fenêtre
Ctrl+A [                                             # Mode copie/scroll

# === Tmux ===
tmux                                                 # Nouvelle session
tmux new -s session_name                             # Session nommée
Ctrl+B D                                             # Détache session
tmux ls                                              # Liste sessions
tmux attach                                          # Rattache dernière
tmux attach -t session_name                          # Rattache session nommée
tmux kill-session -t session_name                    # Tue session
# Dans tmux:
Ctrl+B C                                             # Nouvelle fenêtre
Ctrl+B N                                             # Fenêtre suivante
Ctrl+B P                                             # Fenêtre précédente
Ctrl+B W                                             # Liste fenêtres
Ctrl+B &                                             # Tue fenêtre
Ctrl+B %                                             # Split vertical
Ctrl+B "                                             # Split horizontal
Ctrl+B <-^->v                                          # Navigue panes
Ctrl+B [                                             # Mode copie/scroll
Ctrl+B ]                                             # Colle


[OK] ALIAS & FUNCTIONS


# Ajouter à ~/.bashrc ou ~/.bash_aliases

# === Alias simples ===
alias ll='ls -lah'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias ~='cd ~'
alias c='clear'
alias h='history'
alias j='jobs -l'
alias path='echo -e ${PATH//:/\\n}'

# === Alias Git ===
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git log'
alias gd='git diff'
alias gco='git checkout'
alias gb='git branch'

# === Alias utiles ===
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias mkdir='mkdir -pv'
alias wget='wget -c'
alias df='df -h'
alias du='du -h'
alias free='free -h'
alias ports='netstat -tulanp'
alias psmem='ps auxf | sort -nr -k 4'
alias pscpu='ps auxf | sort -nr -k 3'
alias myip='curl http://ipecho.net/plain; echo'

# === Alias sécurité ===
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ln='ln -i'

# === Fonctions utiles ===

# Créer dossier et y aller
mkcd() {
    mkdir -p "$1" && cd "$1"
}

# Extraire archives
extract() {
    if [ -f "$1" ]; then
        case "$1" in
            *.tar.bz2)   tar xjf "$1"     ;;
            *.tar.gz)    tar xzf "$1"     ;;
            *.bz2)       bunzip2 "$1"     ;;
            *.rar)       unrar x "$1"     ;;
            *.gz)        gunzip "$1"      ;;
            *.tar)       tar xf "$1"      ;;
            *.tbz2)      tar xjf "$1"     ;;
            *.tgz)       tar xzf "$1"     ;;
            *.zip)       unzip "$1"       ;;
            *.Z)         uncompress "$1"  ;;
            *.7z)        7z x "$1"        ;;
            *)           echo "Impossible d'extraire '$1'" ;;
        esac
    else
        echo "'$1' n'est pas un fichier valide"
    fi
}

# Backup fichier
backup() {
    cp "$1"{,.bak-$(date +%Y%m%d-%H%M%S)}
}

# Cherche processus
psgrep() {
    ps aux | grep -v grep | grep -i -e VSZ -e "$1"
}

# Trouve fichier par nom
ff() {
    find . -type f -iname "*$1*"
}

# Trouve dossier par nom
fd() {
    find . -type d -iname "*$1*"
}

# Calcule depuis terminal
calc() {
    echo "scale=2; $*" | bc
}

# Liste toutes les fonctions
list_functions() {
    declare -F | cut -d' ' -f3
}


[OK] CONFIGURATION BASH


# === Fichiers configuration ===
~/.bashrc                                            # Config shell interactif
~/.bash_profile                                      # Config shell login (prioritaire)
~/.profile                                           # Alternative .bash_profile
~/.bash_logout                                       # Exécuté à la déconnexion
~/.bash_aliases                                      # Alias (sourcé par .bashrc)
~/.bash_history                                      # Historique commandes
/etc/bash.bashrc                                     # Config système (tous users)
/etc/profile                                         # Config login système

# === Recharger configuration ===
source ~/.bashrc                                     # Recharge .bashrc
. ~/.bashrc                                          # Alternative
exec bash                                            # Relance shell

# === Options shell ===
set -o                                               # Liste options
set -o noclobber                                     # Empêche écrasement avec >
set +o noclobber                                     # Désactive
set -o vi                                            # Mode vi
set -o emacs                                         # Mode emacs (défaut)
shopt -s cdspell                                     # Corrige fautes cd
shopt -s dirspell                                    # Corrige fautes path
shopt -s autocd                                      # cd automatique
shopt -s globstar                                    # ** pour récursif
shopt -s dotglob                                     # Inclut fichiers cachés dans *
shopt -s extglob                                     # Patterns étendus
shopt -s histappend                                  # Append historique
shopt -s checkwinsize                                # MAJ taille fenêtre
shopt -s cmdhist                                     # Multi-ligne en une entrée
shopt -u                                             # Liste options désactivées

# === Prompt personnalisé ===
# Variables PS1:
# \u : Username
# \h : Hostname (court)
# \H : Hostname (complet)
# \w : Working directory complet
# \W : Working directory (basename)
# \d : Date
# \t : Heure (24h)
# \T : Heure (12h)
# \@ : Heure AM/PM
# \n : Nouvelle ligne
# \$ : $ si user, # si root
# \! : Numéro historique
# \# : Numéro commande
# \j : Nombre jobs

# Exemples PS1:
PS1='\u@\h:\w\$ '                                    # user@host:path$
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '  # Couleurs
PS1='\[\033[0;31m\]\u\[\033[0;33m\]@\[\033[0;36m\]\h \[\033[0;33m\]\w\[\033[00m\]\$ '

# Git dans prompt:
parse_git_branch() {
    git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='\u@\h:\w$(parse_git_branch)\$ '

# === Complétion ===
# Installer bash-completion:
# Ubuntu: sudo apt install bash-completion
# Mac: brew install bash-completion

# Dans .bashrc:
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# Complétion custom:
complete -c command                                  # Complète avec commandes
complete -d cd                                       # Complète avec dossiers
complete -f cat                                      # Complète avec fichiers
complete -W "list of words" command                  # Liste mots


[OK] EXPRESSIONS RÉGULIÈRES


# === Patterns basiques ===
.                                                    # N'importe quel caractère
*                                                    # 0 ou plus répétitions
+                                                    # 1 ou plus répétitions
?                                                    # 0 ou 1 occurrence
^                                                    # Début de ligne
$                                                    # Fin de ligne
\                                                    # Échappement
[]                                                   # Classe caractères
[^]                                                  # Négation classe
()                                                   # Groupe
|                                                    # OU

# === Classes caractères ===
[0-9]                                                # Chiffres
[a-z]                                                # Minuscules
[A-Z]                                                # Majuscules
[a-zA-Z]                                             # Lettres
[a-zA-Z0-9]                                          # Alphanumériques
[^0-9]                                               # Non-chiffres
[:alnum:]                                            # Alphanumériques
[:alpha:]                                            # Lettres
[:digit:]                                            # Chiffres
[:lower:]                                            # Minuscules
[:upper:]                                            # Majuscules
[:space:]                                            # Espaces
[:punct:]                                            # Ponctuation

# === Quantificateurs ===
{n}                                                  # Exactement n
{n,}                                                 # Au moins n
{n,m}                                                # Entre n et m
*                                                    # {0,}
+                                                    # {1,}
?                                                    # {0,1}

# === Exemples ===
grep '^start' file                                   # Commence par "start"
grep 'end file                                     # Finit par "end"
grep '^ file                                       # Lignes vides
grep '[0-9]{3}' file                                 # 3 chiffres consécutifs
grep '\<word\>' file                                 # Mot exact
grep -E '(ab|cd)' file                               # ab OU cd
grep '[^a-z]' file                                   # Pas minuscule
grep '^[A-Z].*\. file                              # Commence majuscule, finit point

# Email:
grep -E '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

# IP:
grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}

# URL:
grep -E 'https?://[a-zA-Z0-9./?=_%:-]*'


[OK] ASTUCES & TIPS


# === Navigation rapide ===
cd -                                                 # Retour dossier précédent
pushd /chemin && popd                                # Aller-retour
dirs -v                                              # Voir stack directories
cd ~2                                                # Va au 3ème dir dans stack

# === Commandes multiples ===
cmd1; cmd2; cmd3                                     # Séquence (toujours)
cmd1 && cmd2 && cmd3                                 # Séquence (si succès)
cmd1 || cmd2                                         # cmd2 si cmd1 échoue
cmd1 & cmd2 &                                        # Parallèle background

# === Substitution rapide ===
!!                                                   # Répète dernière commande
sudo !!                                              # Répète avec sudo
!$                                                   # Dernier argument
!*                                                   # Tous arguments
^old^new                                             # Remplace dans dernière

# === Brace expansion ===
echo {1..10}                                         # 1 2 3 ... 10
echo {a..z}                                          # a b c ... z
echo {01..12}                                        # 01 02 ... 12
mkdir -p projet/{src,docs,tests}                     # Crée sous-dossiers
touch file{1,2,3}.txt                                # file1.txt file2.txt file3.txt
cp fichier{,.bak}                                    # Copie fichier en fichier.bak
mv fichier{.old,.new}                                # Renomme .old en .new

# === Commandes courtes ===
:                                                    # Commande vide (true)
true                                                 # Toujours vrai
false                                                # Toujours faux
yes                                                  # Output "y" infini
yes | command                                        # Répond "y" automatiquement
timeout 10 command                                   # Limite temps exécution

# === Informations rapides ===
type command                                         # Type commande (alias, fonction, built-in)
which command                                        # Chemin exécutable
whereis command                                      # Binaire, source, man
file fichier                                         # Type fichier
stat fichier                                         # Stats détaillées
wc -l fichier                                        # Compte lignes
wc -w fichier                                        # Compte mots

# === Monitoring temps réel ===
watch -n 1 command                                   # Exécute chaque seconde
watch -d command                                     # Highligh différences
watch -n 5 'df -h'                                   # Surveille disque

# === Temps d'exécution ===
time command                                         # Mesure temps
{ time command; } 2> time.log                        # Sauvegarde temps

# === Comparer fichiers ===
cmp file1 file2                                      # Compare binaire
diff -y file1 file2                                  # Côte à côte
vimdiff file1 file2                                  # Dans vim
colordiff file1 file2                                # Diff coloré

# === Checksum ===
md5sum fichier                                       # MD5
sha1sum fichier                                      # SHA1
sha256sum fichier                                    # SHA256
md5sum fichier > checksums.md5                       # Sauvegarde
md5sum -c checksums.md5                              # Vérifie

# === Base64 ===
echo "texte" | base64                                # Encode
echo "dGV4dGU=" | base64 -d                          # Décode
base64 fichier > fichier.b64                         # Encode fichier
base64 -d fichier.b64 > fichier                      # Décode fichier

# === Random ===
echo $RANDOM                                         # Nombre aléatoire
shuf -i 1-100 -n 1                                   # Random 1-100
head -c 16 /dev/urandom | base64                     # String random
uuidgen                                              # UUID

# === Yes/No prompt ===
read -p "Continuer? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo "Oui"
fi

# === Progress bar ===
pv fichier.iso | dd of=/dev/sdX bs=4M                # Avec pv
rsync -av --progress source/ dest/                   # Rsync avec progress

# === Notifications ===
command; notify-send "Terminé"                       # Notification desktop
command && echo "OK" || echo "Erreur"                # Simple
command; say "Terminé"                               # Mac (parole)

# === One-liners utiles ===
# Top 10 commandes utilisées:
history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10

# Trouve fichiers dupliqués:
find . -type f -exec md5sum {} \; | sort | uniq -D -w 32

# Trouve gros fichiers:
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null

# Utilisation disque par dossier:
du -h --max-depth=1 | sort -hr

# Processus utilisant plus mémoire:
ps aux --sort=-%mem | head -10

# Nettoie logs:
find /var/log -name "*.log" -mtime +30 -delete

# Archive et compresse dossier avec date:
tar -czf backup-$(date +%Y%m%d).tar.gz /path/

# Surveille fichier log:
tail -f /var/log/syslog | grep --line-buffered "error"

# Compte fichiers par extension:
find . -type f | sed 's/.*\.//' | sort | uniq -c | sort -rn

# Change extensions:
for f in *.txt; do mv "$f" "${f%.txt}.md"; done


[OK] SÉCURITÉ & BEST PRACTICES


# === Variables entre guillemets ===
# TOUJOURS mettre variables entre guillemets
rm "$fichier"                                        # [OK] BON
rm $fichier                                          # [X] MAUVAIS

# === Vérifier avant suppression ===
if [ -f "$fichier" ]; then
    rm "$fichier"
fi

# === Utiliser [[ ]] au lieu de [ ] ===
if [[ -f "$fichier" ]]; then                         # [OK] Moderne, safer
    echo "existe"
fi

if [ -f "$fichier" ]; then                           # [OK] Compatible POSIX
    echo "existe"
fi

# === Vérifier exit status ===
if command; then
    echo "Succès"
else
    echo "Erreur"
    exit 1
fi

# === Utiliser fonctions ===
# Meilleure organisation et réutilisabilité
fonction() {
    local var="locale"
    # code
}

# === Logger erreurs ===
command 2>> /var/log/script.log
command &>> /var/log/script.log                      # stdout + stderr

# === Valider input utilisateur ===
read -p "Entrez nombre: " num
if ! [[ "$num" =~ ^[0-9]+$ ]]; then
    echo "Erreur: pas un nombre"
    exit 1
fi

# === Path absolu ===
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# === Nettoyage à la sortie ===
cleanup() {
    rm -f /tmp/tempfile.*
}
trap cleanup EXIT

# === Éviter eval ===
eval "$user_input"                                   # [X] DANGEREUX
# Utiliser plutôt des alternatives sûres

# === Permissions strictes ===
chmod 600 fichier-sensible.txt                       # Seulement propriétaire
chmod 700 script-sensible.sh                         # Seulement propriétaire


[OK] DEBUGGING


# === Options debug ===
bash -x script.sh                                    # Trace exécution
bash -n script.sh                                    # Vérifie syntaxe
bash -v script.sh                                    # Verbose
set -x                                               # Active trace
set +x                                               # Désactive trace
set -v                                               # Verbose
set +v                                               # Désactive verbose

# === Dans script ===
#!/bin/bash
set -euo pipefail                                    # Mode strict
set -x                                               # Debug

# === Afficher ligne courante ===
echo "Ligne: $LINENO"

# === Afficher valeurs variables ===
declare -p var                                       # Affiche déclaration
printf "var=%s\n" "$var"                             # Affiche valeur

# === Tracer fonction ===
fonction() {
    echo "Entrée fonction: $FUNCNAME"
    echo "Arguments: $@"
    # code
    echo "Sortie fonction: $FUNCNAME"
}

# === Shellcheck ===
# Installer: sudo apt install shellcheck
shellcheck script.sh                                 # Analyse script
shellcheck -x script.sh                              # Avec sources


═══════════════════════════════════════════════════════════════════════════════
                            RESSOURCES & RÉFÉRENCES
═══════════════════════════════════════════════════════════════════════════════


[OK] DOCUMENTATION GIT

# Officielle
https://git-scm.com/doc                              # Documentation complète
https://git-scm.com/book                             # Pro Git book (gratuit)

# Guides interactifs
https://learngit