Resources attached to the Road To DevOps tutorial https://blog.noobtoroot.xyz/road-to-devops/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

376 lines
21 KiB

<!-- .slide: data-background="#2E2E2E" data-state="nologo-slide" -->
# Utilisation au quotidien
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="c7c96e0e041b6b6805a3a54bfa4f8eec">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Initialisation</h2>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 820px; height: 260px; left: 70px; top: 99px;" data-block-id="bca7b61ddc87bd84f13e2f21bfe3bc52">
<div class="sl-block-content" style="z-index: 12;">
<img src="svg/workflow-init.svg" data-natural-width="180" data-natural-height="57" style=""/>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 600px; left: 180px; top: 420px;" data-block-id="fe35e498e344d1f090457b64cc57f228">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<p><code>$ git init</code></p>
<p>Création d'un dépôt local</p>
<p>Génère le dossier <code>.git</code></p>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="06c16f116e7efcf6d5dd1a9430c589d0">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Ajout de fichiers</h2>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 821px; height: 260px; left: 80px; top: 98px;" data-block-id="c3a50d0519b0bf37e1ff7cb70e398cde">
<div class="sl-block-content" style="z-index: 12;">
<img src="svg/workflow-add.svg" style="" data-natural-width="180" data-natural-height="57"/>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 559px; left: 16px; top: 420px;" data-block-id="d69c7175efdc25f684c9b4ffbc097f7d">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<p style="text-align:left">Ajout de tous les fichiers</p>
<p><code>$ git add .</code></p>
<p style="text-align:left">Ajout d'un fichier en particulier</p>
<p><code>$ git add file1.txt</code></p>
<p style="text-align:left">Ajout de tous les fichiers textes</p>
<p><code>$ git add *.txt</code></p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 361px; left: 575px; top: 467px;" data-block-id="6800b680e993e1f50b9ab289cd1ebed3">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 14;">
<p style="text-align:left">Déplacement de fichiers</p>
<p><code>$ git mv old new</code></p>
<p><code>$ git rm fichier</code></p>
</div>
</div>
<div class="sl-block" data-block-type="line" style="width: auto; height: auto; min-width: 1px; min-height: 1px; left: 560px; top: 420px;" data-block-id="93a64e94f2554edf96e16adcd9a1fc16">
<div class="sl-block-content" data-line-x1="180" data-line-y1="430" data-line-x2="180" data-line-y2="170" data-line-color="#000000" data-line-start-type="none" data-line-end-type="none" style="z-index: 15;">
<svg
xmlns="http://www.w3.org/2000/svg" version="1.1" preserveAspectRatio="xMidYMid" width="1" height="260" viewBox="180 170 1 260">
<line stroke="rgba(0,0,0,0)" stroke-width="15" x1="180" y1="430" x2="180" y2="170"></line>
<line stroke="#000000" stroke-width="2" x1="180" y1="430" x2="180" y2="170"></line>
</svg>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="653c965b620da0491f6c799ae7417b2a">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Commit d'un fichier</h2>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 829px; height: 240px; left: 80px; top: 156px;" data-block-id="adb3b408d7913fb91cb590cab13f5028">
<div class="sl-block-content" style="z-index: 12;">
<img src="svg/workflow-commit.svg" data-natural-width="197" data-natural-height="57" style=""/>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 900px; top: 475px;" data-block-id="abb007c5b740b2d0fcf567fea8e60591">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<p>Commit des fichiers dans l’index</p>
<p><code>$ git commit –m "Description&nbsp;commit"</code></p>
</div>
</div>
@@
## Quand commiter ?
- 1 commit = 1 tâche
- Commit = code stable
**aussi souvent que possible !**
@@
<!-- .slide: class="align-left" -->
## Formattage des commits
<br>
Mettre en place des règles sur le projet.
<br><br>
1 bonne pratique = les règles Google AngularJS.
<br><br>
[https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits)
@@
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 957px; left: 0px; top: 127px;" data-block-id="11b4b840acd709f6c4bf5d332d4533ac">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<p>
<strong>&lt;type&gt;(scope):&lt;sujet&gt;</strong>
</p>
<p style="text-align: left;">type : type de commit (feat, fix, chore, test, docs)</p>
<p style="text-align:left">
<span style="text-align:left">scope : partie du code concerné</span>
</p>
<p style="text-align:left">
<span style="text-align:left">sujet: description </span>
<span style="text-align:center">succincte</span>
</p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 953px; left: 7px; top: 381px;" data-block-id="7db0c488e332ea230d362a622d774589">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<p>
<strong>Exemples</strong>
</p>
<pre><code>
feat(Module): add info method
fix(input[number]): add min/max
docs(Licence): update definition
chore(travis): fix deploy rules
</code></pre>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="e3f18bb826b161bda4ca7d169d6cb446">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<h2>Format des commits</h2>
</div>
</div>
@@
<!-- .slide: class="align-left" -->
## Les commandes usuelles
<br>
Consulter l’état d’un dépôt : `git status`
<br><br>
Consulter l’historique des commits du plus récent au plus ancien : `git log`, `git log --oneline`, `git log --graph`, `gitk`
<br><br>
Basculer vers une version antérieure sur un commit particulier : `git checkout <hash>`
<br><br>
Revenir au commit le plus récent : <br>`git checkout <Nom_Branche>` / `git checkout master`
<br><br>
Récupérer l’état d’un fichier tel qu’il était à lors d’un commit particulier : `git checkout <hash> <fichier>`
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="3087d8556ed915bc8cbe4b79aec38bc0">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Retour arrière</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 600px; left: 80px; top: 121px;" data-block-id="d742534640a8fcf40a1fbdd546fe7f66">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12; text-align: left;">
<p>Retirer un fichier de la "
<strong>stagging area</strong>".
</p>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 950px; height: 323px; left: 10px; top: 230px;" data-block-id="ede54feed6836ffeb92f02b9020d561f">
<div class="sl-block-content" style="z-index: 13;">
<img data-natural-width="197" data-natural-height="67" style="" src="svg/reset-file.svg" data-lazy-loaded=""/>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="77e03633cbd3d02211abd86a52ff42cb">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 10;">
<h2>Retour arrière</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 800px; left: 80px; top: 141px;" data-block-id="98899f24e0ec3a15d3c9cdf9626be00b">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11; text-align: left;">
<p>Restaurer un fichier depuis la
<strong>"stagging area"</strong>.
</p>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 951px; height: 323px; left: 9px; top: 210px;" data-block-id="ccda6ae1bfe86aa21fc1f895e4dfac16">
<div class="sl-block-content" style="z-index: 13;">
<img data-natural-width="197" data-natural-height="67" style="" src="svg/checkout_file.svg" data-lazy-loaded=""/>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 1px;" data-block-id="cdc48b13e462dc90d2d1555c30fe426b">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Retour arrière</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 800px; left: 80px; top: 140px;" data-block-id="b4c450b726622120962316476cfa206e">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12; text-align: left;">
<p>Restaurer un fichier depuis un <strong>commit</strong>.</p>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 960px; height: 326px; left: 0px; top: 278px;" data-block-id="38ef8c88f758a7c9729f41104951750b">
<div class="sl-block-content" style="z-index: 13;">
<img src="svg/checkout_file_commit.svg" data-natural-width="197" data-natural-height="67" style=""/>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="d7d0ce93607d9849f0341483ae6fe9e2">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 10;">
<h2>3 modes de reset</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 800px; left: 83px; top: 162px;" data-block-id="f90d71707d00980683070d644c3bb84a">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<p style="text-align:left">
<strong>Hard : </strong>Perte des "commits" et des fichiers.
</p>
<p style="text-align:left">&nbsp;</p>
<p style="text-align:left">
<strong>Mixed : </strong>mode par défaut, supprime les commit, leur contenu se retrouve dans la "
<strong>working area</strong>".
</p>
<p style="text-align:left">&nbsp;</p>
<p style="text-align:left">
<strong>Soft : </strong>supprime les "commits", leur contenu se retouve and la "
<strong>stagging area</strong>".
</p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 890px; left: 35px; top: 525px;" data-block-id="25b0d448905541396df5c0d9d6bb069f">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13; color: rgb(204, 65, 37);">
<p>
<strong>Ne jamais supprimer un commit distant</strong>
</p>
<p>
<strong>Avoir un "working directory" propre </strong>
</p>
<p>
<strong>(pas de modifications en cours)</strong>
</p>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="d83a473983bb4fc33c131215efc880e2">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Reset Hard</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 600px; left: 148px; top: 420px;" data-block-id="9d3c49ab488127c0d55bf1c79361a4d6">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<p><code>git reset --hard &lt;no_commit&gt;</code></p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 600px; left: 148px; top: 500px;" data-block-id="cac4be0ea0cd8b980f76293017141863">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<p>Le numéro de commit correspond à la position sur laquelle il y a une reposition.</p>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 923px; height: 112px; left: 19px; top: 199px;" data-block-id="d748001c138cecd6ee09f2f7629eeeea">
<div class="sl-block-content" style="z-index: 14;">
<img src="svg/reset-hard.svg" data-natural-width="313" data-natural-height="38" style=""/>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="43e0e752a2c1eb5576812e196e9ecec8">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Reset --mixed</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 600px; left: 148px; top: 420px;" data-block-id="cda979444fe7fdd496452aab21054383">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<p><code>git reset &lt;no_commit&gt;</code></p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 600px; left: 148px; top: 500px;" data-block-id="12ca019b90c105ac7a4a78855dea2d8c">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<p>Reset par défaut toutes les modifications sont mélangées dans la
<strong>working&nbsp;directory</strong>.
</p>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 940px; height: 151px; left: 0px; top: 162px;" data-block-id="bd38d964ad89417e3b55cc5d41a34892">
<div class="sl-block-content" style="z-index: 14;">
<img src="svg/reset-mixed.svg" data-natural-width="280" data-natural-height="45" style=""/>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 2px;" data-block-id="7523574ef76b00b0410199fd088899bc">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Reset --soft</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 600px; left: 192px; top: 421px;" data-block-id="cf0f67893a04e0d3cf5ef9cbcebf45eb">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<p><code>git reset --soft &lt;no_commit&gt;</code></p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 600px; left: 148px; top: 500px;" data-block-id="14ff23b73c157ed87ad27cb0facc6e7b">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<p>Reset toutes les modifications sont dans la
<strong>staging area</strong>.
</p>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 952px; height: 153px; left: 4px; top: 162px;" data-block-id="3c70f6e21759ec1363ebad6020d5f120">
<div class="sl-block-content" style="z-index: 14;">
<img src="svg//reset-soft.svg" data-natural-width="280" data-natural-height="45" style=""/>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 1px;" data-block-id="51170ee9c41b511ad3f94d62319db214">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 10;">
<h2>Modifier le dernier commit</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 800px; left: 80px; top: 162px;" data-block-id="cd533d6660516c190fea2f4c02d431b9">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11; text-align: left;">
<p>Pour corriger le message d'un dernier commit</p>
<p>et/ou ajouter un fichier oublié.</p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 600px; left: 180px; top: 298px;" data-block-id="5339f396c8f548c5a8e5004a396d26d6">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<p><code>git commit --amend &lt;text&gt;</code></p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 651px; left: 186px; top: 445px;" data-block-id="73d8530937332da21c647bc9984f0be0">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 14; color: rgb(204, 65, 37);">
<p>
<strong>Ne fonctionne que si le commit est local !</strong>
</p>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="4bb1905ac8da6e7d478c738f2aae749f">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>Cloner un dépôt</h2>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 800px; left: 101px; top: 140px;" data-block-id="7035eeba54297b202ff55e1ac732959a">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 12;">
<p>Construit un dépôt local à l'image d'un dépôt distant dans le répertoire courant</p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 600px; left: 200px; top: 241px;" data-block-id="cff2e46e8a9eaebe8035195285d25a8b">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 13;">
<p><code>git clone &lt;remote_url&gt;</code></p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; min-width: 30px; min-height: 30px; width: 900px; top: 520px;" data-block-id="bcf1f879ffb72196f70867f26d93e843">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 14;">
<p style="text-align: left;">Plusieurs protocoles sont disponibles : Local, git, ssh/git, http(s)</p>
</div>
</div>
<div class="sl-block" data-block-type="text" style="height: auto; width: 950px; top: 567px;" data-block-id="189535e548a8590325ceb848ab45e7c9">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 15;">
<p><code>git clone git://github.com/jeanbon/project.git</code></p>
<p><code>git clone https://gitlab.com/jeanbon/project.git</code></p>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 653px; height: 226px; left: 167px; top: 292px;" data-block-id="e5523ed176196472a2fcce91f1dfabef">
<div class="sl-block-content" style="z-index: 16;">
<img src="svg/clone.svg" data-natural-width="205" data-natural-height="71" style=""/>
</div>
</div>
@@
<div class="sl-block" data-block-type="text" style="height: auto; width: 960px; left: 0px; top: 0px;" data-block-id="7e2ee5ae2c0844a9cbb82954f18c50f0">
<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Text" style="z-index: 11;">
<h2>En résumé</h2>
</div>
</div>
<div class="sl-block" data-block-type="image" style="min-width: 4px; min-height: 4px; width: 834px; height: 539px; left: 27px; top: 108px;" data-block-id="524dd65327be45c3394f961ca7c68836">
<div class="sl-block-content" style="z-index: 12;">
<img src="svg/recap_process.svg" data-natural-width="198" data-natural-height="128" style=""/>
</div>
</div>