GIT SOUS LE CAPOT
Meetup AFUP Lyon
@Florian_FB

@Florian_FB

Magnifique photo corporate
Florian Bogey
Lead Développeur PHP/Symfony



@Florian_FB
Florian-B
GL events
Oh non encore un talk sur GIT

@Florian_FB
- Créé en 2005 par Linus Torvalds
- Gestion de versions décentralisé
- Open Source
- Versionnage incrémental du code
- Permet branches, fusions et retour en arrière
- Performance
- Utilisé via GitHub, GitLab, etc
GIT

@Florian_FB
La théorie des graphes

-
Ponts de Königsberg : exercice connu pour être à l’origine de la théorie des graphes
-
Calculer un trajet qui fait traverser chaque pont une seule fois et retour au point de départ
@Florian_FB
La théorie des graphes

-
L'historique des commits forme un graphe
-
Commit : un nœud (sommet)
-
Branche : Pointeur un nœud du graphe
-
Merge : Nœud avec plusieurs parents
@Florian_FB
COMMIT
-
Le "cœur" de GIT
-
Différentiel du code
-
Identifiant unique SHA-1
-
Métadonnées
-
Message
-
ATOMIQUE !
@Florian_FB
conventional commits
<type>[optional scope]: <description>
--------------
feat(api): add authentication
Refs: JIRA-1234@Florian_FB
conventional commits
feat : ajout d'une nouvelle fonctionnalité
fix : correction d'un bug
docs : changement dans la documentation
style : Coding style
refactor : refactoring de code
perf : Amélioration de performance
test : ajout ou mise à jour de tests unitaires
build : Compilation du code, dépendances externes
ci : Intégration continue (CI)
chore : autre changement qui ne touche pas les source ou tests
revert : retour à un commit précédent@Florian_FB
voir: https://www.conventionalcommits.org
BRANCHE
-
Référence vers un commit
-
Nouvelle branche = diverger
git branch <name>
git checkout –b <name>@Florian_FB
BRANCHE

@Florian_FB
BRANCHE


@Florian_FB
BRANCHE

@Florian_FB
BRANCHE

@Florian_FB

TAG

-
Référence vers un commit
-
Permet de poser un "flag" sur une branche
-
Généralement on tag les releases sur la main/master
@Florian_FB
HEAD
-
Référence vers un commit
-
Référence dynamique
-
HEAD pointe vers le dernier commit de la branche courante

@Florian_FB
REMOTE
-
Référence vers un commit sur le serveur distant
-
Origin nom par défaut de votre repo distant
@Florian_FB
REMOTE

@Florian_FB
REMOTE

@Florian_FB
Sous le capot

@Florian_FB
Le dossier .git
$ ls -al
drwxrwxr-x 8 florian florian 4096 oct. 30 16:03 .git
-rw-rw-r-- 1 florian florian 66 oct. 30 15:37 index.html
-rw-rw-r-- 1 florian florian 0 oct. 30 11:49 README.md
@Florian_FB
Le dossier .git
~/projets/talk-git/.git (main)$ ls -al
drwxrwxr-x 2 florian florian 4096 oct. 30 11:48 branches
-rw-rw-r-- 1 florian florian 48 oct. 30 16:03 COMMIT_EDITMSG
-rw-rw-r-- 1 florian florian 92 oct. 30 15:34 config
-rw-rw-r-- 1 florian florian 73 oct. 30 11:48 description
-rw-rw-r-- 1 florian florian 21 oct. 30 15:35 HEAD
drwxrwxr-x 2 florian florian 4096 oct. 30 11:48 hooks
-rw-rw-r-- 1 florian florian 289 oct. 30 15:37 index
drwxrwxr-x 2 florian florian 4096 oct. 30 11:48 info
drwxrwxr-x 3 florian florian 4096 oct. 30 11:50 logs
drwxrwxr-x 31 florian florian 4096 oct. 30 16:03 objects
-rw-rw-r-- 1 florian florian 46 oct. 30 15:34 packed-refs
drwxrwxr-x 4 florian florian 4096 oct. 30 11:48 refs
Tout est fichier !
Le dossier .git
$ git branch
feature/login
feature/register
main
@Florian_FB
Le dossier .git
$ git log feature/login
commit f4bb782919b8eddb53bc1f83e3da1c195b83782c (feature/login)
Author: Florian Bogey <florian.bogey@gl-events.com>
Date: Thu Oct 30 15:35:27 2025 +0100
feat(login): handle login form submission
commit 15ee8192e624b95acacc7b3f63717c47dad48851
Author: Florian Bogey <florian.bogey@gl-events.com>
Date: Thu Oct 30 15:35:27 2025 +0100
feat(login): add login page
@Florian_FB
Le dossier .git
$ cd .git/refs/heads/
$ find . -type f -exec ls -al {} \;
-rw-rw-r-- 1 florian florian 41 oct. 30 16:03 ./main
-rw-rw-r-- 1 florian florian 41 oct. 30 15:35 ./feature/register
-rw-rw-r-- 1 florian florian 41 oct. 30 15:35 ./feature/login
@Florian_FB
Le dossier .git
$ cat .git/refs/heads/feature/login
@Florian_FB
Le dossier .git
$ cat .git/refs/heads/feature/login
f4bb782919b8eddb53bc1f83e3da1c195b83782c
@Florian_FB
Le dossier .git
$ git log feature/register
commit 61058a18cd82a3e04af128c4849814c6d5097245 (feature/register)
Author: Florian Bogey <florian.bogey@gl-events.com>
Date: Thu Oct 30 15:35:27 2025 +0100
feat(register): handle user registration
$ cat .git/refs/heads/feature/register
61058a18cd82a3e04af128c4849814c6d5097245
@Florian_FB
Le dossier .git
$ git checkout feature/login
$ cat .git/HEAD@Florian_FB
Le dossier .git
$ git checkout feature/login
$ cat .git/HEAD
ref: refs/heads/feature/login
$ cat .git/refs/heads/feature/login
f4bb782919b8eddb53bc1f83e3da1c195b83782c
$ git log feature/login
commit f4bb782919b8eddb53bc1f83e3da1c195b83782c (HEAD -> feature/login)
Author: Florian Bogey <florian.bogey@gl-events.com>
Date: Thu Oct 30 15:35:27 2025 +0100
feat(login): handle login form submission
@Florian_FB
Le dossier .git
$ git checkout feature/register
$ cat .git/HEAD
ref: refs/heads/feature/register
@Florian_FB
Le dossier .git
$ git log
commit 8d511b2c356ccd6acde53650d74317d47242ca3f (HEAD -> main, tag: 1.0.1)
Author: Florian Bogey <florian.bogey@gl-events.com>
Date: Thu Oct 30 15:37:18 2025 +0100
feat(landing): add amazing text to landing page
commit d1c4b4aab1c2418ebfcb524db8cbee48324ea8e6 (tag: 1.0.0)
Author: Florian Bogey <florian.bogey@gl-events.com>
Date: Thu Oct 30 15:36:14 2025 +0100
feat(landing): add basic landing page
@Florian_FB
Le dossier .git
$ ls -al .git/refs/tags/
-rw-rw-r-- 1 florian florian 41 oct. 30 16:32 1.0.0
-rw-rw-r-- 1 florian florian 41 oct. 30 16:32 1.0.1
$ cat .git/refs/tags/1.0.0
@Florian_FB
Le dossier .git
$ ls -al .git/refs/tags/
-rw-rw-r-- 1 florian florian 41 oct. 30 16:32 1.0.0
-rw-rw-r-- 1 florian florian 41 oct. 30 16:32 1.0.1
$ cat .git/refs/tags/1.0.0
d1c4b4aab1c2418ebfcb524db8cbee48324ea8e6
$ cat .git/refs/tags/1.0.1
8d511b2c356ccd6acde53650d74317d47242ca3f
@Florian_FB
FUSION

@Florian_FB
MERGE

@Florian_FB
MERGE

@Florian_FB
REBASE

@Florian_FB
REBASE

@Florian_FB
COMMANDES UTILES

@Florian_FB
CHerry-pick
$ git cherry-pick <sha-commit>-
I ❤️ cherry-pick
-
Copier un commit vers la branche courante
-
GIT crée un nouveau commit avec un nouvel identifiant
-
Après l'application, le HEAD avance d’un commit
@Florian_FB
REBASE INTERACTIF
$ git rebase -i HEAD~n
$ git rebase -i a1b2c3d-
Réécrire l'historique de la branche : Squash, Supprimer, Modifier, Réordonner...
-
Git ouvre un éditeur listant les commits depuis la base jusqu’au HEAD
-
Git rejoue les commits un par un en fonction des actions
@Florian_FB
REBASE INTERACTIF
pick 15ee819 feat(login): add login page
pick f4bb782 feat(login): handle login form submission
# Rebase 9977451..f4bb782 onto 9977451 (2 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# d, drop <commit> = remove commit
# etc.@Florian_FB
BISECT
$ git bisect start
$ git bisect bad HEAD
$ git bisect good 1.0.0
# Checkout un commit au milieu
$ git bisect good / bad
# Checkout un commit au milieu
$ git bisect good / bad
# etc.
<sha1> is the first bad commit
$ git bisect reset@Florian_FB
REFLOG
$ git reflog
f4bb782 (HEAD -> feature/login) HEAD@{0}: rebase (finish): ...
f4bb782 (HEAD -> feature/login) HEAD@{1}: rebase (start): ...
f4bb782 (HEAD -> feature/login) HEAD@{2}: checkout: ...-
Historique des positions du HEAD (rebase, merge, reset)
-
Commande pompier 🧑🚒 !
-
Permet de retrouver un commit même après un reset --hard
-
Options : RTFM
@Florian_FB
Utiliser Git en ligne de commande !

@Florian_FB
[Meetup AFUP] Git sous le capot
By Florian Bogey
[Meetup AFUP] Git sous le capot
- 0