GIT : Une Introduction

Planche provenant de CommitStrip

Plan

Pourquoi GIT ?

I. Installer git

II. Les bases

III. Pour aller plus loin

Pourquoi git ?

Pourquoi git ? (bis)

Planche provenant de CommitStrip

I. Installer git

Windows, Mac, Linux

Debian / Ubuntu / Mint

sudo apt-get update
sudo apt-get install git

Windows : http://cmder.net/

II. Les bases

Le workflow

Le workflow (bis)

II. Les bases

Vocabulaire

Dépôt (repository) : votre projet

Commit : une sauvegarde de l'état du projet à un instant t

Branche : permet de développer des fonctionnalités (en parallèle) sans affecter le code en production (branche master)

Head : l'état actuel (= référence vers un commit) de votre dossier local, souvent le dernier commit

Origin : nom par défaut (convention) du serveur principal avec lequel votre dossier local peut être synchronisé

Les indispensables

Première fois avec git

git config --global user.name "Jon Snow"
git config --global user.email jon.snow@example.com

Everyday Git in twenty commands or so

git help everyday

Les indispensables (bis)

Créer un nouveau dépôt

Ajouter des fichiers à la validation

Valider les fichiers

Voir le status actuel du dépôt

git init
git status
git add monFichier
git add .
git commit -m "Decrire ici la modification"

Voir les modifications

git diff

Les 3 états

Staging Area

Dossier De Travail

Dépôt (dossier .git)

"Zone de transit"

Checkout

Add

Commit

Travailler avec un serveur

Cloner un dépôt

Envoyer les modifications au serveur

Synchroniser avec la version du serveur (+fusionner)

git clone git@gitlab.ensta.fr:mon_repo.git
git pull origin master
git pull
git log --oneline
git log

Historique des modifications

git push origin master
git push

Avec un ou plusieurs serveurs

Dépôt Local (dossier .git)

Push

Serveur

"origin"

Serveur

"autre_serveur"

Pull

Travailler avec un serveur (bis)

Créer une clé ssh (si besoin)

Ajouter un serveur

Copier la clé publique (puis l'enregistrer sur le serveur)

ssh-keygen -t rsa -C "email@ensta-paristech.fr"
cat ~/.ssh/id_rsa.pub
git push -u origin master

Synchroniser avec le serveur une branche locale

git remote -v

Lister les serveurs

git remote add origin URL_DU_REPO_GIT
git remote set-url origin NOUVELLE_URL_DU_REPO_GIT

Modifier l'url d'un serveur

III. Pour aller plus loin

Serveurs git

How to undo (almost) anything with Git

Oh shit, git!

Git Tips

Interfaces graphiques (GUI)

Tutoriels :  Become a GIT Guru

Cheatsheet

Try GIT

Bonus

	GIT - the stupid content tracker

"git" can mean anything, depending on your mood.

 - random three-letter combination that is pronounceable, and not
   actually used by any common UNIX command.  The fact that it is a
   mispronounciation of "get" may or may not be relevant.
 - stupid. contemptible and despicable. simple. Take your pick from the
   dictionary of slang.
 - "global information tracker": you're in a good mood, and it actually
   works for you. Angels sing, and a light suddenly fills the room. 
 - "goddamn idiotic truckload of sh*t": when it breaks

This is a stupid (but extremely fast) directory content manager.  It
doesn't do a whole lot, but what it _does_ do is track directory
contents efficiently. 

Présentation de GIT par son créateur : Linus Torvald

Git : Une Introduction

By Antonin Raffin

Git : Une Introduction

Introduction au contrôle de version avec le logciel git

  • 2,167