|
|
|
L'objectif de ce qui suit est de prendre en main l'outil de gestion de versions _git_ afin de tracer l'historique d'un développement local en :
|
|
|
|
|
|
|
|
- créant un nouveau dépôt (`git init`)
|
|
|
|
- visualisant l'état du dépôt (`git status`)
|
|
|
|
- produisant des versions (`git add` et `git commit`)
|
|
|
|
- visualisant l'historique (`git log`)
|
|
|
|
- comparant des versions différentes d'un même fichier (`git diff`)
|
|
|
|
|
|
|
|
__N.B.__ : _les manipulations suivante sont faites depuis un terminal Linux-compatible, les commandes ont des équivalents sous Windows_
|
|
|
|
|
|
|
|
## Création d'un dépôt local
|
|
|
|
|
|
|
|
_On suppose que l'on se trouve dans un répertoire local `4git` (vide) où l'on souhaite commencer à développer_
|
|
|
|
|
|
|
|
La création du dépôt local s'effectue via la commande `git init`:
|
|
|
|
```
|
|
|
|
MacBook-Air-749:4git sebastienjean$ git init
|
|
|
|
hint: Using 'master' as the name for the initial branch. This default branch name
|
|
|
|
hint: is subject to change. To configure the initial branch name to use in all
|
|
|
|
hint: of your new repositories, which will suppress this warning, call:
|
|
|
|
hint:
|
|
|
|
hint: git config --global init.defaultBranch <name>
|
|
|
|
hint:
|
|
|
|
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
|
|
|
|
hint: 'development'. The just-created branch can be renamed via this command:
|
|
|
|
hint:
|
|
|
|
hint: git branch -m <name>
|
|
|
|
Initialized empty Git repository in /Users/sebastienjean/4git/.git/
|
|
|
|
MacBook-Air-749:4git sebastienjean$
|
|
|
|
```
|
|
|
|
|
|
|
|
L'existence du dépôt créé se matérialise par la création d'un sous- répértoire caché nommé `.git`, que l'on peut observer soit avec un explorateur de fichiers graphique (en prenant soin d'activer l'affichage des éléments cachés), soit en ligne de commande :
|
|
|
|
```
|
|
|
|
MacBook-Air-749:4git sebastienjean$ ls -al
|
|
|
|
total 0
|
|
|
|
drwxr-xr-x 3 sebastienjean staff 96 Dec 16 10:54 .
|
|
|
|
drwxr-xr-x@ 160 sebastienjean staff 5120 Dec 16 10:45 ..
|
|
|
|
drwxr-xr-x 9 sebastienjean staff 288 Dec 16 10:54 .git
|
|
|
|
MacBook-Air-749:4git sebastienjean$ cd .git
|
|
|
|
MacBook-Air-749:.git sebastienjean$ ls -al
|
|
|
|
total 24
|
|
|
|
drwxr-xr-x 9 sebastienjean staff 288 Dec 16 10:54 .
|
|
|
|
drwxr-xr-x 3 sebastienjean staff 96 Dec 16 10:54 ..
|
|
|
|
-rw-r--r-- 1 sebastienjean staff 23 Dec 16 10:54 HEAD
|
|
|
|
-rw-r--r-- 1 sebastienjean staff 137 Dec 16 10:54 config
|
|
|
|
-rw-r--r-- 1 sebastienjean staff 73 Dec 16 10:54 description
|
|
|
|
drwxr-xr-x 15 sebastienjean staff 480 Dec 16 10:54 hooks
|
|
|
|
drwxr-xr-x 3 sebastienjean staff 96 Dec 16 10:54 info
|
|
|
|
drwxr-xr-x 4 sebastienjean staff 128 Dec 16 10:54 objects
|
|
|
|
drwxr-xr-x 4 sebastienjean staff 128 Dec 16 10:54 refs
|
|
|
|
MacBook-Air-749:.git sebastienjean$
|
|
|
|
```
|
|
|
|
|
|
|
|
Ce répertoire contient des méta-données représentant l'historique, que l'outil _git_ tient à jour au fil des commandes. Les fichiers ne sont pas faits pour être modifiés à la main, à l'exceptioon du fichier `config` qui contient des informations personnalisables de configuration locale du dépôt (voir plus généralement `git config` pour cela)
|
|
|
|
|
|
|
|
|