Exercice : Créer et gérer un projet simple avec Git
-
Initialisation du projet
- Créez un nouveau dossier pour votre projet
- Initialier un dépôt Git dans ce dossier
Fenêtre de terminal mkdir mon-projetcd mon-projetgit init -
Ajout des fichiers
- Créez quelques fichiers (par exemple,
index.html
etstyle.css
). - Ajoutez ces fichiers à l’index.
Fenêtre de terminal touch index.html style.cssgit add index.html style.css`` - Créez quelques fichiers (par exemple,
-
Premier commit
- Faites un commit avec un message descriptif
Fenêtre de terminal git commit -m "Ajout des fichiers initiaux" -
Création et gestion des branches
- Créez une nouvelle branche
- Changez de branche et faites des modifications
Fenêtre de terminal git branch nouvelle-branchegit checkout nouvelle-branchetouch nouveau-fichier.htmlgit add nouveau-fichier.htmlgit commit -m "Ajout d'un nouveau fichier" -
Fusion de branches
- Revenez à la branche principale et fusionnez la nouvelle branche
Fenêtre de terminal git checkout mastergit merge nouvelle-branche -
Partage du projet
- Poussez votre projet sur un dépôt distant (GitHub).
Fenêtre de terminal git remote add origin <https://github.com/votre-utilisateur/votre-projet.git>git push -u origin master