#2 - Git - DAG
-
Upload
rodrigo-branas -
Category
Software
-
view
591 -
download
0
Transcript of #2 - Git - DAG
![Page 1: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/1.jpg)
Rodrigo Branas – @rodrigobranas - http://www.agilecode.com.br
#2 - Git - DAG
![Page 2: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/2.jpg)
Rodrigo [email protected]
http://www.agilecode.com.br
• Arquiteto de Software na Gennera • Professor na Agile Code • Autor na Java Magazine e PacktPub • Palestrante
![Page 3: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/3.jpg)
http://www.youtube.com/rodrigobranas
![Page 4: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/4.jpg)
Obtendo as chaves do castelo...
![Page 5: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/5.jpg)
DAG, ou Directed Acyclic Graph, é o conceito fundamental utilizado pelo Git
para representar a trajetória dos commits ao longo do tempo.
![Page 6: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/6.jpg)
![Page 7: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/7.jpg)
Cada commit representa o estado do repositório em um determinado
momento do tempo.
![Page 8: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/8.jpg)
Criando um commit...
![Page 9: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/9.jpg)
echo a > a.txt echo b > b.txt
![Page 10: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/10.jpg)
git commit
![Page 11: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/11.jpg)
![Page 12: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/12.jpg)
git status
![Page 13: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/13.jpg)
![Page 14: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/14.jpg)
![Page 15: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/15.jpg)
git add a.txt git status
git add b.txt git status
![Page 16: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/16.jpg)
![Page 17: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/17.jpg)
git add -A ou --all git status
![Page 18: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/18.jpg)
![Page 19: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/19.jpg)
Espera, mas como exatamente os arquivos ficam armazenados?
![Page 20: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/20.jpg)
tree .git
![Page 21: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/21.jpg)
![Page 22: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/22.jpg)
O Git utiliza o algoritmo de dispersão criptográfica SHA-1 para calcular um hash de 40 bytes com o objetivo de
indexar, identificar e manter a integridade de cada arquivo.
![Page 23: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/23.jpg)
![Page 24: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/24.jpg)
git hash-object a.txt
![Page 25: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/25.jpg)
![Page 26: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/26.jpg)
git commit -m "a.txt e b.txt"
![Page 27: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/27.jpg)
![Page 28: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/28.jpg)
git status
![Page 29: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/29.jpg)
![Page 30: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/30.jpg)
git log
![Page 31: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/31.jpg)
![Page 32: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/32.jpg)
git log -p ou --patch
![Page 33: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/33.jpg)
![Page 34: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/34.jpg)
E agora, como o commit se relaciona com os arquivos?
![Page 35: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/35.jpg)
git cat-file -p <object>
![Page 36: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/36.jpg)
![Page 37: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/37.jpg)
![Page 38: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/38.jpg)
![Page 39: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/39.jpg)
commit a9ae tree f4b3 parent
tree f4b3 100644 blob 7898 a.txt 100644 blob 6178 b.txt
blob 7898 a
blob 6178 b
![Page 40: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/40.jpg)
Vamos fazer mais um commit...
![Page 41: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/41.jpg)
echo c > c.txt git status git add -A git commit -m "c.txt"
![Page 42: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/42.jpg)
![Page 43: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/43.jpg)
git log
![Page 44: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/44.jpg)
![Page 45: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/45.jpg)
E agora, como o commit se relaciona com os arquivos?
![Page 46: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/46.jpg)
git cat-file -p <object>
![Page 47: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/47.jpg)
![Page 48: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/48.jpg)
![Page 49: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/49.jpg)
![Page 50: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/50.jpg)
commit a9ae tree f4b3 parent
commit 372d tree d11b parent a9ae
tree f4b3 100644 blob 7898 a.txt 100644 blob 6178 b.txt
tree d11b 100644 blob 7898 a.txt 100644 blob 6178 b.txt 100644 blob f2ad c.txt
blob 7898 a
blob 6178 b
blob f2ad c
![Page 51: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/51.jpg)
E se um arquivo for alterado?
![Page 52: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/52.jpg)
![Page 53: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/53.jpg)
git status
![Page 54: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/54.jpg)
![Page 55: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/55.jpg)
git diff
![Page 56: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/56.jpg)
![Page 57: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/57.jpg)
git add -A
![Page 58: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/58.jpg)
![Page 59: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/59.jpg)
git status
![Page 60: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/60.jpg)
![Page 61: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/61.jpg)
git diff
![Page 62: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/62.jpg)
![Page 63: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/63.jpg)
git diff --staged
![Page 64: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/64.jpg)
![Page 65: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/65.jpg)
git commit -m "Alterando c.txt"
![Page 66: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/66.jpg)
![Page 67: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/67.jpg)
git log
![Page 68: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/68.jpg)
![Page 69: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/69.jpg)
E agora, como o commit se relaciona com os arquivos?
![Page 70: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/70.jpg)
git cat-file -p <object>
![Page 71: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/71.jpg)
![Page 72: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/72.jpg)
![Page 73: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/73.jpg)
![Page 74: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/74.jpg)
commit a9ae tree f4b3 parent
commit 372d tree d11b parent a9ae
commit 7f64 tree 6300 parent 372d
tree f4b3 100644 blob 7898 a.txt 100644 blob 6178 b.txt
tree d11b 100644 blob 7898 a.txt 100644 blob 6178 b.txt 100644 blob f2ad c.txt
tree 6300 100644 blob 7898 a.txt 100644 blob 6178 b.txt 100644 blob 16f9 c.txt
blob 7898 a
blob 6178 b
blob f2ad c
blob 16f9 c2
![Page 75: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/75.jpg)
E se apenas o nome do arquivo for alterado?
![Page 76: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/76.jpg)
mv c.txt c2.txt
![Page 77: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/77.jpg)
![Page 78: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/78.jpg)
git status
![Page 79: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/79.jpg)
![Page 80: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/80.jpg)
git add -A git status git commit -m "Alterando o nome do arquivo para c2.txt"
![Page 81: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/81.jpg)
![Page 82: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/82.jpg)
git log --oneline
![Page 83: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/83.jpg)
![Page 84: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/84.jpg)
E agora, como fica?
![Page 85: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/85.jpg)
git cat-file -p <object>
![Page 86: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/86.jpg)
![Page 87: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/87.jpg)
![Page 88: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/88.jpg)
commit a9ae tree f4b3 parent
commit 372d tree d11b parent a9ae
commit 7f64 tree 6300 parent 372d
tree f4b3 100644 blob 7898 a.txt 100644 blob 6178 b.txt
tree d11b 100644 blob 7898 a.txt 100644 blob 6178 b.txt 100644 blob f2ad c.txt
tree 6300 100644 blob 7898 a.txt 100644 blob 6178 b.txt 100644 blob 16f9 c.txt
blob 7898 a
blob 6178 b
blob f2ad c
blob 16f9 c2
commit b274 tree 15eb parent 7f64
tree 15eb 100644 blob 7898 a.txt 100644 blob 6178 b.txt 100644 blob 16f9 c2.txt
![Page 89: #2 - Git - DAG](https://reader030.fdocument.pub/reader030/viewer/2022021507/58ecc64b1a28ab962e8b4603/html5/thumbnails/89.jpg)
Rodrigo Branas
Site: http://www.agilecode.com.br Twitter: @rodrigobranas Facebook: http://www.facebook.com/canalrodrigobranas SlideShare: http://www.slideshare.com/rodrigobranas YouTube: http://www.youtube.com/rodrigobranas LinkedIn: http://br.linkedin.com/in/rodrigobranas +Plus: https://plus.google.com/+RodrigoBranas GitHub: http://www.github.com/rodrigobranas