Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

Welcome to Git - Beginner's Guide

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.


What is Git and Why Use It?

What is 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.

Why do we use it?

  • 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.

Installation

Before you can use the commands below, you must install Git on your computer.

  1. Download Git:
  2. Follow the Setup:
    • Run the downloaded installer and keep the default settings if you are unsure.
  3. Verify Installation:
    • Open your terminal (Command Prompt/PowerShell on Windows, or Terminal on macOS/Linux).
    • Type git --version and press Enter. If it displays a version number, you are ready to go!

Core Git Concepts for Beginners

  • 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.

How to Get Started

Option A: Clone this Repository

Since this repository is read-only, cloning it is a great way to download the files locally to study them.

  1. Click the Clone button on this project's webpage to copy the link.
  2. 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
  3. Need more help? Check out the official GitLab Cloning Documentation (or click the "Help" link next to the clone button on the website).

Option B: Create a New Repository from Scratch (Command Line)

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):

  1. Create an introduction file:

    touch README.md

    (This creates a blank text file named README.md to describe your project.)

  2. Initialize Git in this folder:

    git init

    (This tells Git to start tracking this folder. It creates a hidden .git folder.)

  3. Create and switch to the default branch:

    git checkout -b main

    (This names your main working branch "main".)

  4. 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".)

  5. Save your snapshot:

    git commit -m "first commit"

    (This saves the snapshot to your local history with a message explaining what you did.)

  6. 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".)

  7. Upload your code to the server:

    git push -u origin main

    (This uploads your "main" branch to your online server. The -u flag remembers this connection for next time, so in the future you only need to type git push.)


Option C: Push an Existing Local Repository

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:

  1. 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
  2. Upload your work:

    git push -u origin main

Bienvenue sur Git - Guide du Débutant

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.


Qu'est-ce que Git et pourquoi l'utiliser ?

Qu'est-ce que 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.

Pourquoi l'utiliser ?

  • 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.

Installation

Avant de pouvoir utiliser les commandes ci-dessous, vous devez installer Git sur votre ordinateur.

  1. Télécharger Git :
  2. Suivre l'installation :
    • Lancez l'installateur téléchargé et conservez les options par défaut si vous n'êtes pas sûr.
  3. Vérifier l'installation :
    • Ouvrez votre terminal (Invite de commandes/PowerShell sur Windows, ou Terminal sur macOS/Linux).
    • Tapez git --version et appuyez sur Entrée. Si un numéro de version s'affiche, vous êtes prêt !

Concepts clés pour débuter

  • 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.

Comment démarrer

Option A : Cloner ce dépôt

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.

  1. Cliquez sur le bouton Clone sur la page web de ce projet pour copier le lien.
  2. 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
  3. 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).

Option B : Créer un nouveau dépôt à partir de zéro (Ligne de commande)

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) :

  1. Créer un fichier de présentation :

    touch README.md

    (Cela crée un fichier texte vide nommé README.md pour décrire votre projet.)

  2. Initialiser Git dans ce dossier :

    git init

    (Cela indique à Git de commencer à suivre ce dossier. Cela crée un dossier caché nommé .git.)

  3. Créer et basculer sur la branche principale :

    git checkout -b main

    (Cela nomme votre branche de travail principale "main".)

  4. 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".)

  5. 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.)

  6. 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".)

  7. Envoyer votre code sur le serveur :

    git push -u origin main

    (Cela envoie votre branche "main" sur votre serveur en ligne. L'option -u permet de retenir cette connexion, ainsi vous aurez juste à taper git push les prochaines fois.)


Option C : Envoyer un dépôt local existant

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 :

  1. 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
  2. Envoyer votre travail :

    git push -u origin main

About

Tutorial for newcomers to git

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors