Commit e17e09b3 authored by JackV's avatar JackV

2020 beta version

parent 9fd60990
Pipeline #456 passed with stage
in 1 minute and 49 seconds
<mxfile host="app.diagrams.net" modified="2020-03-22T14:44:20.700Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" etag="W8PR8AIoiCqYpasQW_i4" version="12.8.8" type="device"><diagram id="TsOIuSZ5yv13yciddxsL" name="Page-1">3Vjfb9owEP5r8rgpvwjhcQXWatKkSUhd+zR58TWx5MTIcSDsr5/T2Ekcw2ATbdY+cf7Od7a/u48TOMEyr2852mZfGQbq+C6unWDl+L7nLkL50SCHFpmHUQuknGC1qQc25BfoSIVWBENpbBSMUUG2JpiwooBEGBjinO3NbU+MmqduUQoWsEkQtdHvBIusReOZ2+N3QNJMn+y5ypMjvVkBZYYw2w+gYO0ES86YaK28XgJtyNO8tHGfT3i7i3EoxCUBt/f1l/C++hHn1V2Zx+sa1ocPKssO0Uo9GPuR60Gi7iwOmgjOqgJDk8tzgpt9RgRstihpvHtZeollIqfKrbICF1CfvK7XkSC7B1gOgh/kFhUQKtpU3/ia131fBU9Tmw0qoOOQKnzaZe65kYai5y+o8i2q5j8jtFhMT9X/x1VgcWWRBAX+1OhTrhKKypIkJi9QE/EgbVfZj439caZWq3rgWh30opCXf9AJmsUgqln2Yc8rHddeDrD1VTCqgHwAq3gC57tEIJ6COCc8u6KDis2OFExjHCgSZGde91gV1QnfGJEPGWjLbJjQGzVC+0wVNfxOGSeamYmCaJSo5cFK9NxU3bP/vc/CI30WUUnWDSY7aaaNmaNSANcOec7AZ7clpXK0wCS69YKpdTu7om47rT4OPGd0O5Dqo6HUF9dteKFu/feh2+jExHgl3UZWn7kJekqS+eSzdEyxH0+tyfkVNHl0Lnpn1HV0Av9Rx1fUY/QW9OgvRuPPf6NzNLZ6TEApJh2OYyF2lEwmxMUVhTgadBdL0RiqrybG+EIxRu9jOL6YGOWy/73fbu//NQnWvwE=</diagram></mxfile>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="481px" height="271px" viewBox="-0.5 -0.5 481 271" content="&lt;mxfile host=&quot;app.diagrams.net&quot; modified=&quot;2020-03-22T14:45:36.600Z&quot; agent=&quot;Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0&quot; version=&quot;12.8.8&quot; etag=&quot;SxThCNgujBK45c3zTafR&quot; type=&quot;device&quot;&gt;&lt;diagram id=&quot;ZxUXyE2pfKLBOJUM_Kj4&quot;&gt;3VdNj5swEP01XCs+AoRjN9m2l0qVcujm6NqzYMngyDgJ6a+vWWzAmHSjNkrSnjJ+4xnbz/M8wYtWZfNZoF3xlRNgXuiTxovWXhgGfrZQPy1y6pB0kXRALijRkwZgQ3+CidTonhKorYmScybpzgYxryrA0sKQEPxoT3vlzF51h3JwgA1GzEW/UyKLDl3G/oB/AZoXZuXA154SmckaqAtE+HEERc9etBKcy84qmxWwljzDSxf36Yy335iASl4SEHYBB8T2+mwkTPwAsN6ePJkzC76vCLRhgRc9HQsqYbNDuPUe1S0rrJAl026dFYSE5uzOgv68qlCAlyDFSU3RAQvNkC6R0FB4HAgPDIvFiGwTh/Qd533mgQZlaCbmWYkcVtIfCcqy+7NyV1oWDi0OH1CRj63A1AgzVNcU2xRAQ+WLsn1tb1v7Q6xH62bkWp/MoFL7fDEJ2sEoqh0OYW8jE9dtDshEyzXfCwzWRUskcpCWIi64khHl8QzjBhPAkKQHexNz16BX+MapWnikA/vGF8HkJrvz6Kix1KeJYjtRlEwSdSw4id6qoj/2RYUSzxRKwhQvT4QelJm3ZolqCcI4VMqRz60rxtTjDnfRWBDdUGPJFTXW62o78ryjsZGstpaq/lhjsaux6L/VWHLmeb6+xlKnUHyMXjFO796jpmyGyxvqZ3kF/cz2m+AdJcx2tt9q7gLtpI+vnTCbtJXw8ftT5hSJhFretelMRdOf/haiMc/dVVQz6SAX68bqVn+tnMxVTvpgyvkH/tmp4fAt2k0fvuij518=&lt;/diagram&gt;&lt;/mxfile&gt;"><defs/><g><rect x="0" y="70" width="120" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 90px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">d2601ec</div></div></div></foreignObject><text x="60" y="94" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">d2601ec</text></switch></g><rect x="200" y="70" width="120" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 90px; margin-left: 201px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">7b6a99c</div></div></div></foreignObject><text x="260" y="94" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">7b6a99c</text></switch></g><path d="M 200 90 L 126.37 90" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 121.12 90 L 128.12 86.5 L 126.37 90 L 128.12 93.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><ellipse cx="260" cy="20" rx="60" ry="20" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 20px; margin-left: 201px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><div>master</div></div></div></div></foreignObject><text x="260" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">master</text></switch></g><path d="M 260 40 L 260 63.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 260 68.88 L 256.5 61.88 L 260 63.63 L 263.5 61.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="360" y="150" width="120" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 170px; margin-left: 361px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0cafcc7</div></div></div></foreignObject><text x="420" y="174" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">0cafcc7</text></switch></g><path d="M 360 150 L 324.5 114.5" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 320.79 110.79 L 328.22 113.27 L 324.5 114.5 L 323.27 118.22 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><ellipse cx="420" cy="250" rx="60" ry="20" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 250px; margin-left: 361px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">test</div></div></div></foreignObject><text x="420" y="254" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">test</text></switch></g><path d="M 420 230 L 420 196.37" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 420 191.12 L 423.5 198.12 L 420 196.37 L 416.5 198.12 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://desk.draw.io/support/solutions/articles/16000042487" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text></a></switch></svg>
\ No newline at end of file
<mxfile host="app.diagrams.net" modified="2020-03-22T14:47:53.300Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" etag="p6FnmMwNLPAMSZgXKLOw" version="12.8.8" type="device"><diagram id="TsOIuSZ5yv13yciddxsL" name="Page-1">3VjbjpswEP0aHlthbiGP3STdVaVKlSJtN0+VF2YByeDImIT062sWm5uTJm1pyO5TxjOesX1mjsfEsBdpec/wNv5KQyCGZYalYS8Ny0Lm3BE/leZQa2aOVysiloRyUqtYJz9BeUptkYSQ9yZySglPtn1lQLMMAt7TYcbovj/thZL+qlscgaZYB5jo2u9JyONa67tmq3+AJIrVysiUlhSryVKRxzik+47KXhn2glHKayktF0Aq8BQutd/nE9ZmYwwyfonD/WP5xXksfvhp8ZCn/qqE1eGDjLLDpJAHDi3PRBDIPfODAoLRIguhioUM+24fJxzWWxxU1r1IvdDFPCXSLKMC41Ce3C5qQBDVAzQFzg5iinRwJGyybiyF677NAlLQxp0MKD8sEx81kVtshCDh+QOoLA2q2bOH5/Ppobo9rGwNKw0kyMJPFT/FKCA4z5OgjwuUCX8SsinlTSV/dOVoWXZMy4MaZGLzTypANeh4VcPW7XWk/OrNQahdBYMMiAPQggVwvko4ZhHwc8TTM9rJmHskYUrHgGCe7PrbPZZFucI3moiDdLjVLxgHDQqhPqb06t4pw0BuP5DtDQLVOGiBXouqOfbf15lzpM48IsC6C5OdEKNKTHHOgSmDWKdj08uSENFa4EpXXB+9hqOT8dYdkbcNVzcdyxnedqi66TH1v/PWuZS3zvsgrneiZVyJuJ5WaGaAX4JgNnkzHUJs+VOTcjYCKY82RnSGXkdb8G+JPCIhvQsJaU3JR2s+6H/WG22kvlZjHHJ+U92xgWQyIs5HJOKg011MxV5XvRoZ/QvJ6L2P5jgxGZH+rLVQ4CD3Brvj5J+aaMw369v61kSXPlon7ZHaPW6PRMvmZfbPtBTD9n+4enr7b6a9+gU=</diagram></mxfile>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="481px" height="281px" viewBox="-0.5 -0.5 481 281"><defs/><g><rect x="0" y="80" width="120" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 100px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">d2601ec</div></div></div></foreignObject><text x="60" y="104" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">d2601ec</text></switch></g><rect x="200" y="80" width="120" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 100px; margin-left: 201px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">7b6a99c</div></div></div></foreignObject><text x="260" y="104" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">7b6a99c</text></switch></g><path d="M 200 100 L 126.37 100" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 121.12 100 L 128.12 96.5 L 126.37 100 L 128.12 103.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><ellipse cx="420" cy="20" rx="60" ry="20" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 20px; margin-left: 361px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><div>master</div></div></div></div></foreignObject><text x="420" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">master</text></switch></g><path d="M 420 40 L 420 73.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 420 78.88 L 416.5 71.88 L 420 73.63 L 423.5 71.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="360" y="160" width="120" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 180px; margin-left: 361px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0cafcc7</div></div></div></foreignObject><text x="420" y="184" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">0cafcc7</text></switch></g><path d="M 360 160 L 324.5 124.5" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 320.79 120.79 L 328.22 123.27 L 324.5 124.5 L 323.27 128.22 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><ellipse cx="420" cy="260" rx="60" ry="20" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 260px; margin-left: 361px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">test</div></div></div></foreignObject><text x="420" y="264" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">test</text></switch></g><path d="M 420 240 L 420 206.37" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 420 201.12 L 423.5 208.12 L 420 206.37 L 416.5 208.12 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="360" y="80" width="120" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 100px; margin-left: 361px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">21c4157</div></div></div></foreignObject><text x="420" y="104" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">21c4157</text></switch></g><path d="M 360 100 L 326.37 100" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 321.12 100 L 328.12 96.5 L 326.37 100 L 328.12 103.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://desk.draw.io/support/solutions/articles/16000042487" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text></a></switch></svg>
\ No newline at end of file
## Di cosa parliamo oggi?
![](assets/git_fire.png)
---
## ATTENZIONE
Tutti i comandi trattati in queste slide possono modificare in modo permanente
il repo git.
State Attenti
(Good news: git non cancella mai in modo implicito informazioni)
----
### Internals di Git
---
![](assets/git_internals.png)
---
### tl;dr
* I *commit* sono oggetti con un puntatore al padre ed un puntatore ad un
"pacchetto di file"
* I pacchetti file sono compressi e contengono lo stato integrale del repo al
momento del commit
* un *tag* è un puntatore ad un commit
* un *branch* è un tag che si muove in avanti ogni volta che si esegue un commit
* `HEAD` punta al branch corrente
(la questione è leggermente piu complicata, vedi [qui](https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain) )
----
## git reset
---
### `git reset <mode> <commit>`
`git reset` permette di spostare `HEAD` a `<commit>`
Le mode comuni sono:
* `--soft`: sposta l'`HEAD`
* `--mixed` (default): sposta l'`HEAD` e resetta l'index
* `--hard`: sposta l'`HEAD` e cancella tutti i cambiamenti successivi
----
## git rebase
Il ritorno
---
### Rebase come strumento correttivo
`git rebase -i <commit fine>`
Operazioni:
* reword: permette di cambiare il messaggio di commit
* edit: permette di modificare i file
* squash: "comprime" il commit con il precedente
* drop: elimina il commit
----
## git gc
![](assets/mop.png)
---
Che succede?
```
git reset --soft HEAD~1
<modifichiamo file>
git commit
```
---
Come fare se volete cancellare i file *subito*
```
git reflog expire --expire-unreachable=now
```
----
Ok, ma se voglio fare modifiche **grosse**?
---
## reset, rebase
![](assets/exc.jpg)
---
## filter-branch
<img src="assets/b288.jpg" style="width: 100%;max-width: 100%"></img>
---
## git filter-branch --index-filter
permette di eseguire cambiamenti solo all'index
(ovvero si possono eseguire solo comandi `git`)
---
## git filter-branch --tree-filter
si possono eseguire una serie di comandi arbitrari sul working tree
(è molto piu lento dato che c'è da fare il checkout per ogni commit)
----
# Domande?
......@@ -97,9 +97,9 @@
<section data-external-replace="./slides/intro.html"></section>
<section data-charset="utf-8"
data-markdown="./slides/content.md"
data-separator="^\r?\n---\r?\n$"
data-separator="^\r?\n----\r?\n$"
data-separator-notes="^Notes:"
data-separator-vertical="^\r?\n----\r?\n$">
data-separator-vertical="^\r?\n---\r?\n$">
</section>
<section data-external-replace="./slides/outro.html"></section>
</div>
......
# Intro e outro dentro l'HTML
## What we will talk about today
Il markdown contiene solo il contenuto.
* Changing past git commits
* Rewriting git history
* Deleting files permanently in git
Di base si possono fare le slide anche in HTML se si vogliono animazioni buffe.
### tl;dr
<img src="assets/doctor.png" style="max-height: 40%" />
---
## Warning
All the commands in this presentation modify the git
history in one way or another, this can lead to
problems on shared projects and/or data loss.
----
This is a long dash -- made of two little dashes (`--`).
# Git Internals
### I promise it will be short
---
## Diff
A diff describes a change in a textual file
```diff
--- foo.txt 2020-03-22 15:01:25.425435217 +0100
+++ foo_2.txt 2020-03-22 15:01:43.028767920 +0100
@@ -1 +1 @@
-foo
+bar
```
It is the basic building block of every VCS
---
## Commit
The **commit** is the building block of a git history
It is composed of:
* An unique sha1 hash (compulsory)
* A commit message
* One (or more) father sha1s
* None or more file diffs
Generally a commit represents a 'snapshot' of all the project files
---
## Branches and Tags
* **Branches** and **Tags** are both pointers to a specific commit (sha1)
* Branches 'move' forward when you **`git commit`**, tags don't
* **HEAD** is a special pointer that points to the curretly checked out branch
---
![](assets/git_internals.png)
---
This dash is even longer --- and it is made of three little dashes (`---`).
## Remotes
"Quoting" is fun and easy. `"`Plain quoting`"` is ugly.
A **remote** in git is another git repository
Generally this means your repo on github/gitlab/gitea/etc.
**origin** is the name of the remote when you `git clone`
(es. [https://github.com/torvals/linux]() )
---
## More on branches
There are 2 types of branches:
* Local branches (es. **master**)
* Remote branches (es. **origin/master**)
A local branch can __track__ a remote branch, which means that
* **push**es from the local branch will go to the tracked remote branch
* **pull**s will be merged to the tracking branch
By default when you `git clone` git sets up the `master` branch to track `origin/master`
---
## Merges and fast-forwardability
![](assets/branch-ff.svg)
##### vs.
![](assets/branch-noff.svg)
---
We say that a branch A is fast-forwardable w.r.t. branch B iff
there is no bifurcation between A and B.
Why is this important?
* A merge of a fast-forwardable branch always succeeds (just move B to point to A)
* **git pull** and **git push** do not break only on fast forwardable branches (e.g. _master_ and _origin/master_)
---
## Forcing a push on a non-ff branch
If you have a branch that has diverged, you need to use **`git push --force`**
Note that once you do this, every person that has cloned your repo will need
to **`git pull --force`** and probably come to your house with torch and pitchfork.
**tl;dr `git push --force` responsibly**
----
# Heading level 1
# Ok enough theory
## Heading level 2
<img src="assets/bored.png" />
### Heading level 3
---
#### Heading level 4
## Time to break a git repo!
There are **no** more heading levels.
<img src="assets/explosion.gif" style="max-height: 50%" />
----
<x-section-title>This is a section title</x-section-title>
## amending commits
![](assets/chisel.png)
---
If you want the section title in the top-right cornet
you can add **&lt;x-section-title&gt;title&lt;/x-section-title&gt;** in the slide
How many times happened that you `git commit`ed and then realized that:
* There were files to include
* You made a typo in your code
* You broke your tests
**` git commit --amend `** is the perfect tool for these situations
---
```bash
# Add the missing files
$ git add missing.txt
# and then add it in the current commit
$ git commit --amend
```
----
```python
import sys
## Undoing a lot of commits at once
x = 1 + 2
![](assets/shovel.jpg)
if x > 2:
pass
---
### git reset
`git reset` allows us to move **HEAD** (our current branch) to **`<commit>`**
There are 3 modes:
* `--soft`: simply move `HEAD` (this is also what happens in a ff)
* `--mixed` (default): move `HEAD` and reset index (file is still present in the working directory)
* `--hard`: move `HEAD` and reset index and working directory
----
## git gc
![](assets/mop.png)
---
Let's say I run this
```
git reset --soft HEAD~1
<make some changes>
git commit
```
What happened to the data that was in the initial **HEAD**?
---
Why doesn't **`git gc`** remove the commit?
try:
with open('/dev/null') as f:
pass
except IOError:
raise Exception('Error!')
finally:
sys.exit()
```
git fsck --unreachable --dangling --no-reflogs
git reflog expire --expire=now --all
git gc --prune=now
```
----
## Rebase
![](assets/exc.jpg)
---
## Rebase on branches
Rebase, in its simplest form does the following:
1. given a branch, find at which commit history has diverged
2. compute the diff for each commit past the split
3. reapply each diff onto the current branch (conflicts apply)
4. for each new diff applied make a new commit with the original message
5. once all the commits are applied, delete the original branch
---
## Interactive Rebase
Rebase can also be used to touch-up a commit history
**`git rebase -i <end commit>`**
Once run a file will be opened with __$EDITOR__
Possible operations:
* reword: change the commit message
* edit: change the file just before they were committed
* squash/fixup: apply the changes in this commit to the previous commit
* drop: delete the commit entirely
----
# What if I need to change a lot of files?
---
## filter-branch
<img src="assets/b288.jpg" style="width: 100%;max-width: 100%"></img>
---
## git filter-branch --index-filter
Allows to apply changes only to the index
(basically only *git* commands are allowed)
---
## git filter-branch --tree-filter
Allows us to run multiple commands on each commit
(it is much slower than index-filter since each individual commit
needs to be checked out)
----
- Do you remember bullet list?
```python
bullet_list = ["Do you remember bullet list?"]
```
- You can also allign code to bullet lists!
```python
bullet_list.append("You can also allign code to bullet lists!")
```
- It's not too hard!
```python
if not hard:
bullet_list.append("It's not too hard!")
```
\ No newline at end of file
# Questions?
<section class="intro">
<h1>Corsi Punto Croce 2018</h1>
<h2>Come fare gli orli</h2>
<h1>Corsi Git 2020</h1>
<h2>Disaster Recovery</h2>
<img src="./poul/img/logo-text-white.svg"/>
<p>Autore &lt;email@email.com&gt;</p>
</section>
\ No newline at end of file
<p>Giacomo Vercesi &lt;jackv@poul.org&gt;</p>
</section>
......@@ -3,9 +3,9 @@
<img class="logo" src="./poul/img/logo-notext-white.svg"/>
<p>Rilasciato sotto licenza Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International</p>
<p>Released under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International</p>
<img class="cc" src="./poul/img/creativecommons-by-nc-sa.svg"/>
<p>Autore &lt;email@email.com&gt;</p>
</section>
\ No newline at end of file
<p>Giacomo Vercesi &lt;jackv@poul.org&gt;</p>
</section>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment