Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
git:gitminimal [2019/10/21 14:56] – Emmanuel Bruno | git:gitminimal [2023/09/20 18:52] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 34: | Ligne 34: | ||
< | < | ||
+ | < | ||
test@pc-bruno ~$ ssh-keygen | test@pc-bruno ~$ ssh-keygen | ||
Generating public/ | Generating public/ | ||
Ligne 55: | Ligne 56: | ||
| ..E + | | | ..E + | | ||
+-----------------+ | +-----------------+ | ||
+ | </ | ||
</ | </ | ||
Ligne 65: | Ligne 67: | ||
< | < | ||
+ | < | ||
test@pc-bruno $ git config --global user.name | test@pc-bruno $ git config --global user.name | ||
test@pc-bruno $ git config --global user.email | test@pc-bruno $ git config --global user.email | ||
test@pc-bruno $ git config --global push.default simple | test@pc-bruno $ git config --global push.default simple | ||
+ | </ | ||
</ | </ | ||
Ligne 76: | Ligne 80: | ||
Pour créer un entrepôt, on utilise la commande '' | Pour créer un entrepôt, on utilise la commande '' | ||
< | < | ||
+ | < | ||
test@pc-bruno ~$ mkdir monProjet | test@pc-bruno ~$ mkdir monProjet | ||
test@pc-bruno ~$ cd monProjet/ | test@pc-bruno ~$ cd monProjet/ | ||
test@pc-bruno monProjet$ git init | test@pc-bruno monProjet$ git init | ||
Dépôt Git vide initialisé dans / | Dépôt Git vide initialisé dans / | ||
+ | </ | ||
</ | </ | ||
Ligne 86: | Ligne 92: | ||
Pour cloner un repository existant (dont on connait l' | Pour cloner un repository existant (dont on connait l' | ||
- | Par exemple, | + | Par exemple, |
+ | * en ssh pour un projet privé si votre clé à été ajoutée | ||
+ | * en http sinon [[https:// | ||
+ | |||
+ | <note important> | ||
Pour le cloner : | Pour le cloner : | ||
< | < | ||
- | /tmp ❯❯❯ git clone git@github.com: | + | < |
+ | /tmp ❯❯❯ git clone git@github.com: | ||
Clonage dans ' | Clonage dans ' | ||
remote: Counting objects: 17, done. | remote: Counting objects: 17, done. | ||
Ligne 98: | Ligne 109: | ||
Vérification de la connectivité... fait. | Vérification de la connectivité... fait. | ||
/tmp ❯❯❯ cd sandboxm1 | /tmp ❯❯❯ cd sandboxm1 | ||
+ | </ | ||
</ | </ | ||
Ligne 118: | Ligne 130: | ||
Quand un entrepôt est créé avec la commande '' | Quand un entrepôt est créé avec la commande '' | ||
< | < | ||
+ | < | ||
/ | / | ||
origin git@github.com: | origin git@github.com: | ||
origin git@github.com: | origin git@github.com: | ||
+ | </ | ||
</ | </ | ||
Ligne 133: | Ligne 147: | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ git status | test@pc-bruno sandboxgit$ git status | ||
Sur la branche master | Sur la branche master | ||
Ligne 168: | Ligne 183: | ||
rien à valider, la copie de travail est propre | rien à valider, la copie de travail est propre | ||
+ | </ | ||
</ | </ | ||
Ligne 173: | Ligne 189: | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ git log | test@pc-bruno sandboxgit$ git log | ||
commit af73a0bcec8c38076a86e6758cdb088ce520f485 | commit af73a0bcec8c38076a86e6758cdb088ce520f485 | ||
Ligne 186: | Ligne 203: | ||
dummy fixes #99 closes #99 | dummy fixes #99 closes #99 | ||
... | ... | ||
+ | </ | ||
</ | </ | ||
On peut vérifier ce qui a changé à distance ('' | On peut vérifier ce qui a changé à distance ('' | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ git remote update | test@pc-bruno sandboxgit$ git remote update | ||
Récupération de origin | Récupération de origin | ||
Ligne 198: | Ligne 217: | ||
rien à valider, la copie de travail est propre | rien à valider, la copie de travail est propre | ||
+ | </ | ||
</ | </ | ||
Ligne 205: | Ligne 225: | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ echo " | test@pc-bruno sandboxgit$ echo " | ||
test@pc-bruno sandboxgit$ git add test.txt | test@pc-bruno sandboxgit$ git add test.txt | ||
Ligne 228: | Ligne 249: | ||
To ssh:// | To ssh:// | ||
| | ||
+ | </ | ||
</ | </ | ||
Ligne 241: | Ligne 263: | ||
==== Quels fichiers versionner ? ==== | ==== Quels fichiers versionner ? ==== | ||
Tous les fichiers ne doivent pas être déposé sur le système de gestion de version. | Tous les fichiers ne doivent pas être déposé sur le système de gestion de version. | ||
- | Les détails sont donnés ici : http:// | + | Les détails sont donnés ici : http:// |
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
Ligne 250: | Ligne 272: | ||
Comme nous l' | Comme nous l' | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ git log | test@pc-bruno sandboxgit$ git log | ||
commit 53fa162ffda184e6fdf9fdaa93fc60ae8b24d58a | commit 53fa162ffda184e6fdf9fdaa93fc60ae8b24d58a | ||
Ligne 268: | Ligne 291: | ||
dummy fixes #99 closes #99 | dummy fixes #99 closes #99 | ||
... | ... | ||
+ | </ | ||
</ | </ | ||
Ligne 274: | Ligne 298: | ||
Il est possible de voir ce qui s'est passé pour un commit donné : | Il est possible de voir ce qui s'est passé pour un commit donné : | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ git show 53fa162ffda184e6fdf9fdaa93fc60ae8b24d58a | test@pc-bruno sandboxgit$ git show 53fa162ffda184e6fdf9fdaa93fc60ae8b24d58a | ||
commit 53fa162ffda184e6fdf9fdaa93fc60ae8b24d58a | commit 53fa162ffda184e6fdf9fdaa93fc60ae8b24d58a | ||
Ligne 288: | Ligne 313: | ||
hello | hello | ||
+encore du texte | +encore du texte | ||
+ | </ | ||
</ | </ | ||
Ligne 293: | Ligne 319: | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ git log --abbrev-commit --pretty=oneline | test@pc-bruno sandboxgit$ git log --abbrev-commit --pretty=oneline | ||
53fa162 Ajout de précisions | 53fa162 Ajout de précisions | ||
af73a0b Création d'un fichier texte à mon nom | af73a0b Création d'un fichier texte à mon nom | ||
... | ... | ||
+ | </ | ||
</ | </ | ||
Il est aussi possible de voir ce qui a changé entre deux commit avec la commande '' | Il est aussi possible de voir ce qui a changé entre deux commit avec la commande '' | ||
< | < | ||
+ | < | ||
test@pc-bruno sandboxgit$ git diff af73a0b | test@pc-bruno sandboxgit$ git diff af73a0b | ||
diff --git a/test.txt b/test.txt | diff --git a/test.txt b/test.txt | ||
Ligne 309: | Ligne 338: | ||
hello | hello | ||
+encore du texte | +encore du texte | ||
+ | </ | ||
</ | </ | ||
Ligne 319: | Ligne 349: | ||
Les commandes suivantes permettent de créer un entrepôt '' | Les commandes suivantes permettent de créer un entrepôt '' | ||
< | < | ||
+ | < | ||
test@pc-bruno ~$ mkdir monProjetCentral && cd monProjetCentral && git --bare init | test@pc-bruno ~$ mkdir monProjetCentral && cd monProjetCentral && git --bare init | ||
Dépôt Git vide initialisé dans / | Dépôt Git vide initialisé dans / | ||
Ligne 334: | Ligne 365: | ||
origin / | origin / | ||
origin / | origin / | ||
+ | </ | ||
</ | </ | ||
Ligne 340: | Ligne 372: | ||
Nous allons maintenant ajouter un fichier README dans '' | Nous allons maintenant ajouter un fichier README dans '' | ||
< | < | ||
+ | < | ||
test@pc-bruno ~$ cd monProjet1/ | test@pc-bruno ~$ cd monProjet1/ | ||
test@pc-bruno monProjet1$ echo " | test@pc-bruno monProjet1$ echo " | ||
Ligne 352: | Ligne 385: | ||
To / | To / | ||
* [new branch] | * [new branch] | ||
+ | </ | ||
</ | </ | ||
et mettre à jour '' | et mettre à jour '' | ||
< | < | ||
+ | < | ||
test@pc-bruno monProjet1$ cd ../ | test@pc-bruno monProjet1$ cd ../ | ||
test@pc-bruno monProjet2$ git pull | test@pc-bruno monProjet2$ git pull | ||
Ligne 363: | Ligne 398: | ||
Depuis / | Depuis / | ||
* [nouvelle branche] master | * [nouvelle branche] master | ||
+ | </ | ||
</ | </ | ||
Ligne 369: | Ligne 405: | ||
Par exemple, on modifie le fichier README dans monProjet1 et on pousse la modification : | Par exemple, on modifie le fichier README dans monProjet1 et on pousse la modification : | ||
< | < | ||
+ | < | ||
test@pc-bruno monProjet1$ echo "Modif depuis 1">> | test@pc-bruno monProjet1$ echo "Modif depuis 1">> | ||
[master 5cebb57] chgt depuis 1 | [master 5cebb57] chgt depuis 1 | ||
Ligne 377: | Ligne 414: | ||
To / | To / | ||
| | ||
+ | </ | ||
</ | </ | ||
puis on modifie aussi README dans monProjet2 **sans avoir mis à jour** (donc sans faire de pull). | puis on modifie aussi README dans monProjet2 **sans avoir mis à jour** (donc sans faire de pull). | ||
< | < | ||
+ | < | ||
test@pc-bruno monProjet2$ echo "Modif depuis 2">> | test@pc-bruno monProjet2$ echo "Modif depuis 2">> | ||
test@pc-bruno monProjet2$ git commit -m "chgt depuis 2" && git push | test@pc-bruno monProjet2$ git commit -m "chgt depuis 2" && git push | ||
Ligne 393: | Ligne 432: | ||
astuce: (par exemple 'git pull ...') avant de pousser à nouveau. | astuce: (par exemple 'git pull ...') avant de pousser à nouveau. | ||
astuce: Voir la 'Note à propos des avances rapides' | astuce: Voir la 'Note à propos des avances rapides' | ||
+ | </ | ||
</ | </ | ||
Ligne 398: | Ligne 438: | ||
< | < | ||
+ | < | ||
test@pc-bruno monProjet2$ git pull | test@pc-bruno monProjet2$ git pull | ||
remote: Counting objects: 5, done. | remote: Counting objects: 5, done. | ||
Ligne 407: | Ligne 448: | ||
CONFLIT (contenu) : Conflit de fusion dans README | CONFLIT (contenu) : Conflit de fusion dans README | ||
La fusion automatique a échoué ; réglez les conflits et validez le résultat. | La fusion automatique a échoué ; réglez les conflits et validez le résultat. | ||
+ | </ | ||
</ | </ | ||
Dans le cas le contenu du fichier en conflit est modifié par git pour indiquer les différences des versions : | Dans le cas le contenu du fichier en conflit est modifié par git pour indiquer les différences des versions : | ||
< | < | ||
+ | < | ||
test@pc-bruno monProjet2$ cat README | test@pc-bruno monProjet2$ cat README | ||
Hello | Hello | ||
Ligne 418: | Ligne 461: | ||
Modif depuis 1 | Modif depuis 1 | ||
>>>>>>> | >>>>>>> | ||
+ | </ | ||
</ | </ | ||
Ligne 425: | Ligne 469: | ||
< | < | ||
+ | < | ||
test@pc-bruno monProjet2$ git add README | test@pc-bruno monProjet2$ git add README | ||
test@pc-bruno monProjet2$ git commit -m " | test@pc-bruno monProjet2$ git commit -m " | ||
Ligne 438: | Ligne 483: | ||
To / | To / | ||
| | ||
+ | </ | ||
</ | </ | ||
On peut alors éventuellement mettre à jour monProjet1. | On peut alors éventuellement mettre à jour monProjet1. | ||
< | < | ||
+ | < | ||
test@pc-bruno monProjet1$ git pull | test@pc-bruno monProjet1$ git pull | ||
remote: Counting objects: 10, done. | remote: Counting objects: 10, done. | ||
Ligne 453: | Ligne 500: | ||
| | ||
1 file changed, 2 insertions(+) | 1 file changed, 2 insertions(+) | ||
+ | </ | ||
</ | </ | ||