Update Gestion de versions avec hébergement du dépôt sur un serveur GitLab, les bases authored by Sebastien Jean's avatar Sebastien Jean
......@@ -555,6 +555,8 @@ sebastienjean@MacBook-Air-749 gitlab-bases % git log --pretty="format:%h %s %an
sebastienjean@MacBook-Air-749 gitlab-bases %
```
> 👀 le joker `%D` dans le format passé au paramètre `--pretty` de la commande `git log` permet montre les pointeurs
```bash
sebastienjean@MacBook-Air-749 gitlab-bases % sebastienjean@MacBook-Air-749 gitlab-bases % git status
On branch main
......@@ -862,3 +864,78 @@ La situation résultante est illustrée ci-dessous :
#### Synchronisation montante à partir du dépôt `clone 2`
Toujours à partir du dépôt `clone 2`, on se synchronise dans le sens montant avec la commande `git push` :
```bash
sebastienjean@MacBook-Air-749 gitlab-bases % git push
To https://gitlab.iut-valence.fr/jeans/gitlab-bases.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://gitlab.iut-valence.fr/jeans/gitlab-bases.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
```
L'opération échoue car les deux historiques (local et distant) se contradisent :
* le dépot local demande à raccrocheer le commit `4` après le commit `2`
* le dépôt distant ne peut pas raccrocher `4` à `2` car `3` est déjà le successeur de `2`
> ⚠️ Le serveur n'autorise jamaais les situations de **divergence non résolue**. Ici, la situation reviendrait à avoir une séparation de l'historique en 2 chronologies (branches) parallèles. La divergence doit d'abord être résolue localement par le développeur qui la constate.
#### Synchronisation descendante à partir du dépôt `clone 2`
Toujours à partir du dépôt `clone 2`, on se synchronise dans le sens descendant avec la commande `git pull` :
```bash
sebastienjean@MacBook-Air-749 gitlab-bases % git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 314 bytes | 78.00 KiB/s, done.
From https://gitlab.iut-valence.fr/jeans/gitlab-bases
899b42b..b6c752a main -> origin/main
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Merge made by the 'recursive' strategy.
unFichier.txt | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
```
On vérifie l'état du dépôt et on en déduit que :
```bash
sebastienjean@MacBook-Air-749 gitlab-bases % git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
```
```bash
sebastienjean@MacBook-Air-749 gitlab-bases % git log --pretty="format:%h %s %an %D" --graph
* 1275819 Merge branch 'main' of https://gitlab.iut-valence.fr/jeans/gitlab-bases sebastienjean HEAD -> main
|\
| * b6c752a Nouvelle modification du fichier unFichier.txt sebastienjean origin/main, origin/HEAD
* | d9d3e8b Ajout du fichier unAutreFichier.txt sebastienjean
|/
* 899b42b Ajout d'une ligne à unFichier.txt sebastienjean
* 425ba5e ajout d'un fichier sebastienjean
* 23b7e54 Initial commit Sebastien Jean
sebastienjean@MacBook-Air-749 gitlab-bases %
```
> 👀 l'option `--graph` de la commande `git log` permet de représenter l'**historique sous forme de graphe**, ce qui permet de voir les divergences et leur résolution.
\ No newline at end of file