This guide is designed for complete beginners to help you understand what Git is, why we use it, and how to get started with your very first repository.
Note
Version française disponible plus bas !
Une version entièrement traduite en français est disponible dans la seconde moitié de ce document. Vous pouvez faire défiler la page vers le bas ou cliquer ici pour y accéder directement.
Important
This repository is Read-Only!
You can download (clone) this repository to practice, but you cannot upload (push) changes back to it. For testing commands like git push, please create your own personal test repository on the server first, and replace the placeholder URLs in the examples with your own repository link: https://git.epfl-rocket-team.ch/YOUR_USERNAME/your-test-repo.git.
Git is a Version Control System (VCS). Think of it as a highly advanced "undo" button and a time machine for your project's files. It tracks every change made to your code, code files, and documents over time.
- Track History: You can see exactly what changes you made, when you made them, and why.
- Safety Net: If you make a mistake and your code stops working, you can easily revert back to a previous working version.
- Collaboration: It allows multiple people to work on the same project simultaneously without overwriting each other's work.
- Backup: Hosting platforms (like GitLab, GitHub, or the EPFL Rocket Team Git server) store your project safely in the cloud.
Before you can use the commands below, you must install Git on your computer.
- Download Git:
- Follow the Setup:
- Run the downloaded installer and keep the default settings if you are unsure.
- Verify Installation:
- Open your terminal (Command Prompt/PowerShell on Windows, or Terminal on macOS/Linux).
- Type
git --versionand press Enter. If it displays a version number, you are ready to go!
- Repository (Repo): A folder where Git tracks your project files and their history.
- Commit: A snapshot of your files at a specific point in time. Think of it as saving your progress in a game.
- Remote: A version of your repository hosted on the internet (e.g., on
git.epfl-rocket-team.ch). - Clone: Copying a remote repository from the internet to your local computer.
Since this repository is read-only, cloning it is a great way to download the files locally to study them.
- Click the Clone button on this project's webpage to copy the link.
- Open your terminal, navigate to where you want the folder to be, and run:
git clone https://git.epfl-rocket-team.ch/EPFLRocketTeam/welcome-to-git.git
- Need more help? Check out the official GitLab Cloning Documentation (or click the "Help" link next to the clone button on the website).
To practice making changes and uploading them, you need to create your own personal test project on the web interface first. Once created, open your terminal inside a blank folder on your computer and run these commands step-by-step (make sure to replace YOUR_USERNAME/your-test-repo with your actual repository path):
-
Create an introduction file:
touch README.md
(This creates a blank text file named
README.mdto describe your project.) -
Initialize Git in this folder:
git init
(This tells Git to start tracking this folder. It creates a hidden
.gitfolder.) -
Create and switch to the default branch:
git checkout -b main
(This names your main working branch "main".)
-
Prepare the file to be saved:
git add README.md
(This stages your file, telling Git: "I want to include this file in my next snapshot".)
-
Save your snapshot:
git commit -m "first commit"(This saves the snapshot to your local history with a message explaining what you did.)
-
Link your local project to your online server repository:
git remote add origin https://git.epfl-rocket-team.ch/YOUR_USERNAME/your-test-repo.git
(This connects your local files to your personal online test repository and names it "origin".)
-
Upload your code to the server:
git push -u origin main
(This uploads your "main" branch to your online server. The
-uflag remembers this connection for next time, so in the future you only need to typegit push.)
If you have already initialized Git on your computer and have some commits ready, but you want to link it to your personal test repository on the server:
-
Link your local folder to your personal online repository:
git remote add origin https://git.epfl-rocket-team.ch/YOUR_USERNAME/your-test-repo.git
-
Upload your work:
git push -u origin main
Ce guide est conçu pour les débutants complets afin de vous aider à comprendre ce qu'est Git, pourquoi nous l'utilisons, et comment démarrer avec votre tout premier dépôt.
Important
Ce dépôt est en Lecture Seule !
Vous pouvez télécharger (cloner) ce dépôt pour vous entraîner, mais vous ne pouvez pas y envoyer (push) de modifications. Pour tester les commandes comme git push, veuillez d'abord créer votre propre dépôt de test personnel sur le serveur, et remplacez les liens d'exemple par le lien de votre dépôt : https://git.epfl-rocket-team.ch/VOTRE_NOM_D_UTILISATEUR/votre-depot-de-test.git.
Git est un système de contrôle de version (VCS). Imaginez-le comme un bouton "annuler" ultra-performant et une machine à voyager dans le temps pour les fichiers de votre projet. Il enregistre chaque modification apportée à votre code et à vos documents au fil du temps.
- Historique complet : Vous pouvez voir exactement quelles modifications ont été faites, quand, et par qui.
- Sécurité : Si vous faites une erreur et que votre code ne fonctionne plus, vous pouvez facilement revenir à une version précédente qui fonctionnait.
- Travail en équipe : Il permet à plusieurs personnes de travailler sur le même projet en même temps sans écraser le travail des autres.
- Sauvegarde : Les plateformes d'hébergement (comme GitLab, GitHub ou le Git de l'EPFL Rocket Team) sauvegardent votre projet en toute sécurité dans le cloud.
Avant de pouvoir utiliser les commandes ci-dessous, vous devez installer Git sur votre ordinateur.
- Télécharger Git :
- Suivre l'installation :
- Lancez l'installateur téléchargé et conservez les options par défaut si vous n'êtes pas sûr.
- Vérifier l'installation :
- Ouvrez votre terminal (Invite de commandes/PowerShell sur Windows, ou Terminal sur macOS/Linux).
- Tapez
git --versionet appuyez sur Entrée. Si un numéro de version s'affiche, vous êtes prêt !
- Dépôt (Repository / Repo) : Un dossier dans lequel Git enregistre vos fichiers et tout leur historique.
- Commit : Une capture (sauvegarde) de vos fichiers à un instant T. C'est l'équivalent d'une sauvegarde dans un jeu vidéo.
- Remote (Dépôt distant) : La version de votre dépôt stockée sur internet (par exemple, sur
git.epfl-rocket-team.ch). - Clone : L'action de copier un dépôt distant depuis internet vers votre ordinateur local.
Comme ce dépôt est en lecture seule, le cloner est un excellent moyen de télécharger les fichiers localement pour les étudier.
- Cliquez sur le bouton Clone sur la page web de ce projet pour copier le lien.
- Ouvrez votre terminal, naviguez vers l'endroit où vous voulez placer le dossier, et lancez :
git clone https://git.epfl-rocket-team.ch/EPFLRocketTeam/welcome-to-git.git
- Besoin d'aide ? Consultez la documentation officielle de GitLab sur le clonage (ou cliquez sur le lien d'aide à côté du bouton "Clone" sur le site).
Pour vous entraîner à faire des modifications et à les envoyer en ligne, vous devez d'abord créer votre propre projet de test sur l'interface web. Une fois créé, ouvrez votre terminal dans un dossier vide sur votre ordinateur et tapez ces commandes pas à pas (veillez à remplacer VOTRE_NOM_D_UTILISATEUR/votre-depot-de-test par le chemin de votre dépôt) :
-
Créer un fichier de présentation :
touch README.md
(Cela crée un fichier texte vide nommé
README.mdpour décrire votre projet.) -
Initialiser Git dans ce dossier :
git init
(Cela indique à Git de commencer à suivre ce dossier. Cela crée un dossier caché nommé
.git.) -
Créer et basculer sur la branche principale :
git checkout -b main
(Cela nomme votre branche de travail principale "main".)
-
Préparer le fichier pour la sauvegarde :
git add README.md
(Cela prépare votre fichier, disant à Git : "Je veux inclure ce fichier dans ma prochaine sauvegarde".)
-
Enregistrer la sauvegarde (Commit) :
git commit -m "first commit"(Cela enregistre la sauvegarde dans votre historique local avec un message expliquant ce que vous avez fait.)
-
Lier votre projet local à votre dépôt personnel sur le serveur :
git remote add origin https://git.epfl-rocket-team.ch/VOTRE_NOM_D_UTILISATEUR/votre-depot-de-test.git
(Cela connecte vos fichiers locaux à votre dépôt de test en ligne et le nomme "origin".)
-
Envoyer votre code sur le serveur :
git push -u origin main
(Cela envoie votre branche "main" sur votre serveur en ligne. L'option
-upermet de retenir cette connexion, ainsi vous aurez juste à tapergit pushles prochaines fois.)
Si vous avez déjà initialisé Git sur votre ordinateur et effectué des sauvegardes (commits), mais que vous voulez le connecter à votre dépôt de test personnel sur le serveur :
-
Lier votre dossier local à votre dépôt en ligne personnel :
git remote add origin https://git.epfl-rocket-team.ch/VOTRE_NOM_D_UTILISATEUR/votre-depot-de-test.git
-
Envoyer votre travail :
git push -u origin main