Upload
rodrigo-branas
View
600
Download
0
Embed Size (px)
Citation preview
Rodrigo Branas – @rodrigobranas - http://www.agilecode.com.br
#2 - Git - DAG
Rodrigo [email protected]
http://www.agilecode.com.br
• Arquiteto de Software na Gennera • Professor na Agile Code • Autor na Java Magazine e PacktPub • Palestrante
http://www.youtube.com/rodrigobranas
Obtendo as chaves do castelo...
DAG, ou Directed Acyclic Graph, é o conceito fundamental utilizado pelo Git
para representar a trajetória dos commits ao longo do tempo.
Cada commit representa o estado do repositório em um determinado
momento do tempo.
Criando um commit...
echo a > a.txt echo b > b.txt
git commit
git status
git add a.txt git status
git add b.txt git status
git add -A ou --all git status
Espera, mas como exatamente os arquivos ficam armazenados?
tree .git
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.
git hash-object a.txt
git commit -m "a.txt e b.txt"
git status
git log
git log -p ou --patch
E agora, como o commit se relaciona com os arquivos?
git cat-file -p <object>
commit a9ae tree f4b3 parent
tree f4b3 100644 blob 7898 a.txt 100644 blob 6178 b.txt
blob 7898 a
blob 6178 b
Vamos fazer mais um commit...
echo c > c.txt git status git add -A git commit -m "c.txt"
git log
E agora, como o commit se relaciona com os arquivos?
git cat-file -p <object>
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
E se um arquivo for alterado?
git status
git diff
git add -A
git status
git diff
git diff --staged
git commit -m "Alterando c.txt"
git log
E agora, como o commit se relaciona com os arquivos?
git cat-file -p <object>
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
E se apenas o nome do arquivo for alterado?
mv c.txt c2.txt
git status
git add -A git status git commit -m "Alterando o nome do arquivo para c2.txt"
git log --oneline
E agora, como fica?
git cat-file -p <object>
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
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