Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

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 Brunogit:gitminimal [2023/09/20 18:52] (Version actuelle) – modification externe 127.0.0.1
Ligne 34: Ligne 34:
  
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno ~$ ssh-keygen  test@pc-bruno ~$ ssh-keygen 
 Generating public/private rsa key pair. Generating public/private rsa key pair.
Ligne 55: Ligne 56:
 |      ..E +      | |      ..E +      |
 +-----------------+ +-----------------+
 +</nowiki>
 </konsole> </konsole>
  
Ligne 65: Ligne 67:
  
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno $ git config --global user.name    "John Doe" test@pc-bruno $ git config --global user.name    "John Doe"
 test@pc-bruno $ git config --global user.email   "john.doe@example.com" test@pc-bruno $ git config --global user.email   "john.doe@example.com"
 test@pc-bruno $ git config --global push.default simple test@pc-bruno $ git config --global push.default simple
 +</nowiki>
 </konsole> </konsole>
  
Ligne 76: Ligne 80:
 Pour créer un entrepôt, on utilise la commande ''git init'' : Pour créer un entrepôt, on utilise la commande ''git init'' :
 <konsole> <konsole>
 +<nowiki>
 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 /home/test/monProjet/.git/ Dépôt Git vide initialisé dans /home/test/monProjet/.git/
 +</nowiki>
 </konsole> </konsole>
  
Ligne 86: Ligne 92:
 Pour cloner un repository existant (dont on connait l'adresse) on utilise la commande ''git clone''. Pour cloner un repository existant (dont on connait l'adresse) on utilise la commande ''git clone''.
  
-Par exemple, le projet sandbox des M1 de 2016 sur github ([[https://github.com/dptinfoutln/sandboxm1]]) possède un dépôt Git. La page d'accueil du projet indique l'adresse de l'entrepôt (dans le bouton clone)([[git@github.com:dptinfoutln/sandboxm1.git]])+Par exemple, ce projet github ([[https://github.com/dptinfoutln/m120192020_helloworld]]) possède un dépôt Git. La page d'accueil du projet indique l'adresse de l'entrepôt (dans le bouton clone) 
 +  * en ssh pour un projet privé si votre clé à été ajoutée [[git@github.com:dptinfoutln/m120192020_helloworld.git]].  
 +  * en http sinon [[https://github.com/dptinfoutln/m120192020_helloworld.git]] 
 + 
 +<note important>Créer un compte github avec votre vrai nom, activer l'offre étudiant pour avoir des entrepôts privé et poster votre identifiant sur slack pour être ajouté à l'équipe du M1.</note>
  
 Pour le cloner : Pour le cloner :
 <konsole> <konsole>
-/tmp ❯❯❯ git clone git@github.com:dptinfoutln/sandboxm1.git+<nowiki> 
 +/tmp ❯❯❯ git clone git@github.com:dptinfoutln/m120192020_helloworld.git
 Clonage dans 'sandboxm1'... Clonage dans 'sandboxm1'...
 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
 +</nowiki>
 </konsole> </konsole>
  
Ligne 118: Ligne 130:
 Quand un entrepôt est créé avec la commande ''clone'', un lien vers l'entrepôt d'origine est conservé. Pour obtenir la liste des entrepôts distants associés à un entrepôt on utilise la commande ''git remote''. Quand un entrepôt est créé avec la commande ''clone'', un lien vers l'entrepôt d'origine est conservé. Pour obtenir la liste des entrepôts distants associés à un entrepôt on utilise la commande ''git remote''.
 <konsole> <konsole>
 +<nowiki>
 /t/sandboxm1 ❯❯❯ git remote -v                                                                    master /t/sandboxm1 ❯❯❯ git remote -v                                                                    master
 origin git@github.com:dptinfoutln/sandboxm1.git (fetch) origin git@github.com:dptinfoutln/sandboxm1.git (fetch)
 origin git@github.com:dptinfoutln/sandboxm1.git (push) origin git@github.com:dptinfoutln/sandboxm1.git (push)
 +</nowiki>
 </konsole> </konsole>
  
Ligne 133: Ligne 147:
  
 <konsole> <konsole>
 +<nowiki>
 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
 +</nowiki>
 </konsole> </konsole>
  
Ligne 173: Ligne 189:
  
 <konsole> <konsole>
 +<nowiki>
 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
 ... ...
 +</nowiki>
 </konsole>  </konsole> 
  
 On peut vérifier ce qui a changé à distance (''git remote update'' puis ''git status'') : On peut vérifier ce qui a changé à distance (''git remote update'' puis ''git status'') :
 <konsole> <konsole>
 +<nowiki>
 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
 +</nowiki>
 </konsole> </konsole>
  
Ligne 205: Ligne 225:
  
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno sandboxgit$ echo "encore du texte">>test.txt test@pc-bruno sandboxgit$ echo "encore du texte">>test.txt
 test@pc-bruno sandboxgit$ git add test.txt  test@pc-bruno sandboxgit$ git add test.txt 
Ligne 228: Ligne 249:
 To ssh://gitedu@lsis.univ-tln.fr/sandboxgit.git To ssh://gitedu@lsis.univ-tln.fr/sandboxgit.git
    4160dd6..53fa162  master -> master    4160dd6..53fa162  master -> master
 +</nowiki>
 </konsole> </konsole>
  
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://bruno.lsis.univ-tln.fr/git/gitignore+Les détails sont donnés ici : http://bruno.univ-tln.fr/git/gitignore
  
 <WRAP center round important 60%> <WRAP center round important 60%>
Ligne 250: Ligne 272:
 Comme nous l'avons déjà vu ''git log'' permet de consulter le journal des modifications:  Comme nous l'avons déjà vu ''git log'' permet de consulter le journal des modifications: 
 <konsole> <konsole>
 +<nowiki>
 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
 ... ...
 +</nowiki>
 </konsole> </konsole>
  
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é :
 <konsole> <konsole>
 +<nowiki>
 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
 +</nowiki>
 </konsole> </konsole>
  
Ligne 293: Ligne 319:
  
 <konsole> <konsole>
 +<nowiki>
 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
 ... ...
 +</nowiki>
 </konsole> </konsole>
  
 Il est aussi possible de voir ce qui a changé entre deux commit avec la commande ''git diff'' soit en indiquant deux commit entre lesquels faire la différence soit un seul (l'état courant sera alors utilisé) : Il est aussi possible de voir ce qui a changé entre deux commit avec la commande ''git diff'' soit en indiquant deux commit entre lesquels faire la différence soit un seul (l'état courant sera alors utilisé) :
 <konsole> <konsole>
 +<nowiki>
 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
 +</nowiki>
 </konsole> </konsole>
  
Ligne 319: Ligne 349:
 Les commandes suivantes permettent de créer un entrepôt ''monProjetCentral'' de type bare et deux clone "Projet1" et "Projet2". Les commandes suivantes permettent de créer un entrepôt ''monProjetCentral'' de type bare et deux clone "Projet1" et "Projet2".
 <konsole> <konsole>
 +<nowiki>
 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 /home/test/monProjetCentral/ Dépôt Git vide initialisé dans /home/test/monProjetCentral/
Ligne 334: Ligne 365:
 origin /home/test/monProjetCentral (fetch) origin /home/test/monProjetCentral (fetch)
 origin /home/test/monProjetCentral (push) origin /home/test/monProjetCentral (push)
 +</nowiki>
 </konsole> </konsole>
  
Ligne 340: Ligne 372:
 Nous allons maintenant ajouter un fichier README dans ''monProjet1'', le pousser dans l'entrepôt central. Nous allons maintenant ajouter un fichier README dans ''monProjet1'', le pousser dans l'entrepôt central.
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno ~$ cd monProjet1/ test@pc-bruno ~$ cd monProjet1/
 test@pc-bruno monProjet1$ echo "Hello">README && git add README test@pc-bruno monProjet1$ echo "Hello">README && git add README
Ligne 352: Ligne 385:
 To /home/test/monProjetCentral To /home/test/monProjetCentral
  * [new branch]      master -> master  * [new branch]      master -> master
 +</nowiki>
 </konsole> </konsole>
  
 et mettre à jour ''monProjet2''. et mettre à jour ''monProjet2''.
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno monProjet1$ cd ../monProjet2/ test@pc-bruno monProjet1$ cd ../monProjet2/
 test@pc-bruno monProjet2$ git pull test@pc-bruno monProjet2$ git pull
Ligne 363: Ligne 398:
 Depuis /home/test/monProjetCentral Depuis /home/test/monProjetCentral
  * [nouvelle branche] master     -> origin/master  * [nouvelle branche] master     -> origin/master
 +</nowiki>
 </konsole> </konsole>
  
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 :
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno monProjet1$ echo "Modif depuis 1">>README && git add READMEtest@pc-bruno monProjet1$ git commit -m "chgt depuis 1" && git push test@pc-bruno monProjet1$ echo "Modif depuis 1">>README && git add READMEtest@pc-bruno monProjet1$ git commit -m "chgt depuis 1" && git push
 [master 5cebb57] chgt depuis 1 [master 5cebb57] chgt depuis 1
Ligne 377: Ligne 414:
 To /home/test/monProjetCentral To /home/test/monProjetCentral
    0a1efb5..5cebb57  master -> master    0a1efb5..5cebb57  master -> master
 +</nowiki>
 </konsole> </konsole>
  
 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).
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno monProjet2$ echo "Modif depuis 2">>README && git add README test@pc-bruno monProjet2$ echo "Modif depuis 2">>README && git add README
 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' dans 'git push --help' pour plus d'information. astuce: Voir la 'Note à propos des avances rapides' dans 'git push --help' pour plus d'information.
 +</nowiki>
 </konsole> </konsole>
  
Ligne 398: Ligne 438:
  
 <konsole> <konsole>
 +<nowiki>
 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.
 +</nowiki>
 </konsole> </konsole>
  
 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 :
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno monProjet2$ cat README  test@pc-bruno monProjet2$ cat README 
 Hello Hello
Ligne 418: Ligne 461:
 Modif depuis 1 Modif depuis 1
 >>>>>>> 5cebb57a2be60b9f7fbbe49b5735c256d1d285bf >>>>>>> 5cebb57a2be60b9f7fbbe49b5735c256d1d285bf
 +</nowiki>
 </konsole> </konsole>
  
Ligne 425: Ligne 469:
  
 <konsole> <konsole>
 +<nowiki>
 test@pc-bruno monProjet2$ git add README  test@pc-bruno monProjet2$ git add README 
 test@pc-bruno monProjet2$ git commit -m "Résolution du conflit" test@pc-bruno monProjet2$ git commit -m "Résolution du conflit"
Ligne 438: Ligne 483:
 To /home/test/monProjetCentral To /home/test/monProjetCentral
    5cebb57..c982ffe  master -> master    5cebb57..c982ffe  master -> master
 +</nowiki>
 </konsole> </konsole>
  
 On peut alors éventuellement mettre à jour monProjet1. On peut alors éventuellement mettre à jour monProjet1.
 <konsole> <konsole>
 +<nowiki>
 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:
  README | 2 ++  README | 2 ++
  1 file changed, 2 insertions(+)  1 file changed, 2 insertions(+)
 +</nowiki>
 </konsole> </konsole>