SlideShare a Scribd company logo
1 of 39
Download to read offline
Git é seu amigo



                               Celestino Gomes




Saturday, September 12, 2009                     1
O quê?

       • Criado em 2005 por Linus Torvalds

             • Necessidade, linux-kernel-devs


       • Originalmente, era um engine para VCS

       • Fluxo de trabalho distribuído

       • Prevenção de corrupção acidental

       • Alta performance




Saturday, September 12, 2009                     2
Características básicas

       • Controle de versão distribuido (DVCS)

       • Gerenciamento de conteúdo e não arquivos

       • Branches como unidade de trabalho

       • SHA1 para associação e verificação

       • Staging index

       • Não é o subversion



Saturday, September 12, 2009                        3
Como funciona?




Saturday, September 12, 2009   4
Diretório .git

       • Diretório .git na raíz de cada projeto

       • Arquivos de configuração (.git/config)

       • Index (.git/index)

       • Hooks (.git/hooks)

       • Object Database (.git/objects)

       • References (.git/refs)



Saturday, September 12, 2009                      5
Object Database
     • Quatro tipos de objetos:

          • Blob, Tree, Commit e Tag


     • Todos registrados/gravados da mesma maneira




Saturday, September 12, 2009                         6
Object Database - Loose format



                   conteudo


                   header + conteudo


                    “2e6f9b0d5885b6010f9167787445617f553a735f”


                   zlib(header + conteudo)



                   .git/objects/2e/6f9b0d5885b6010f9167787445617f553a735f



Saturday, September 12, 2009                                                7
Object Database - Packed format

                   .git/objects/2e/6f9b0d5885b6010f9167787445617f553a735f

                   .git/objects/0b/772ec8eb9ae8952c3c1e56a9ffbe49385cc83a

                   .git/objects/72/16b02627bc3d6ef57008f7ff67f0f8f13f488e



                                                              git-gc



          .git/objects/pack/pack-0bc9a42eb66d7ae36bf44af8ff5a3888e8a02d12.idx

         .git/objects/pack/pack-0bc9a42eb66d7ae36bf44af8ff5a3888e8a02d12.pack




Saturday, September 12, 2009                                                                                                            8
Digamos que os objetos listados referenciem o mesmo arquivo, com conjuntos pequenos de diferenças geradas ao longo do tempo. Usar uma
ferramenta de manutenção (git-gc, por exemplo) vai compactar os objetos e armazená-los em ‘/pack’.
Object Database - Blob

                                        Rakefile   blob: 2e6f9b



                               active_content.rb   blob: 7034fe



                          active_content_spec.rb   blob: a738fc




Saturday, September 12, 2009                                      9
Object Database - Tree

                                              /    tree: 1fba94



                                        Rakefile          blob: 2e6f9b



                                            /lib          tree: 3ef95a



                               active_content.rb                  blob: 7034fe



                                          /spec           tree: 34ba74



                  active_content_spec.rb                          blob: a738fc




Saturday, September 12, 2009                                                     10
Object Database - Commit

                                                   commit: 8d1ab4


                                              /     tree: 1fba94



                                        Rakefile    blob: 2e6f9b



                                            /lib    tree: 3ef95a



                               active_content.rb    blob: 7034fe



                                          /spec     tree: 34ba74



                  active_content_spec.rb            blob: a738fc




Saturday, September 12, 2009                                        11
Object Database - Commit

                                          commit: 8d1ab4   commit: 61db26


                                     /     tree: 1fba94     tree: 1fba94



                               Rakefile    blob: 2e6f9b     blob: 41d300



                                   /lib    tree: 3ef95a     tree: 3ef95a



                    active_content.rb      blob: 7034fe     blob: 7034fe



                                 /spec     tree: 34ba74     tree: 34ba74



       active_content_spec.rb              blob: a738fc     blob: 2a03fb




Saturday, September 12, 2009                                                12
Object Database - Tag

                                                    tag: 6ee1f2


                                                   commit: 8d1ab4


                                              /     tree: 1fba94


                                        Rakefile    blob: 2e6f9b


                                            /lib    tree: 3ef95a


                               active_content.rb    blob: 7034fe



                                          /spec     tree: 34ba74


                  active_content_spec.rb            blob: a738fc




Saturday, September 12, 2009                                        13
Object Database - Resumindo




Saturday, September 12, 2009         14
Object Database - Resumo

       • Blob é o menor objeto do git

       • Tree contém Trees e Blobs

       • Commit contém Commits, Trees e Blobs

       • Tags contém/apontam um Commit




Saturday, September 12, 2009                    15
References

                   .git/refs/heads/master                     master                      HEAD



                                                         commit: 8d1ab4


                                              /           tree: 1fba94


                                Rakefile                  blob: 2e6f9b


                                        /lib              tree: 3ef95a


                   active_content.rb                      blob: 7034fe



                                      /spec               tree: 34ba74


       active_content_spec.rb                             blob: a738fc




Saturday, September 12, 2009                                                                                                             16
Um branch é um ponteiro para um commit. Quando se avança um branch adicionando commits, o que está acontecendo, por baixo dos panos, é
mudar o ponteiro do branch para um novo commit.
Staging Index


                                 lib.rb      Untracked

                                   $ git add lib.rb


                                 lib.rb          Staged

                               $ git commit -m “lib.rb”


                                 lib.rb      Commited


Saturday, September 12, 2009                              17
Flow básico




Saturday, September 12, 2009   18
Criação de repositórios

       Criando um novo repositório

          $ rails my_blog
          ...
          $ cd my_blog
          $ git init
          $ git add .
          $ git commit -m “Initial commit”

      Criando um repositório a partir de um outro

          $ git clone git://github.com/tinogomes/my_blog_app_with_bug.git
          $ cd my_blog_app_with_bug
          $ git branch
          master



Saturday, September 12, 2009                                                19
Trabalhando em um branch remoto


            $ cd my_blog_app_with_bug
            $ git checkout -b refactoring origin/refactoring
            ... após modificações
            $ echo tmp > .gitignore
            $ git add .
            $ git commit -m “outras modificacoes”
            $ git pull
            $ git push origin refactoring




Saturday, September 12, 2009                                   20
Indo além do flow básico




Saturday, September 12, 2009     21
Adicionando arquivos



                                    $ git add <dir>


                               $ git add <dir>/<arquivo>



                                   $ git add *.rb



                                $ git add . (cuidado)




Saturday, September 12, 2009                               22
Trabalhando com branch local

          $ cd my_blog_app_with_bug
          $ git branch meu_branch_local
          ...
          $ git checkout master
          $ git pull . master
          $ git push origim master



          $ git branch -d meu_branch_local




Saturday, September 12, 2009                 23
Navegando pelo histórico

         $ git log --stat

         commit 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8
         Author: Celestino Gomes <celestino@HDU15121-ADIGITAL.local>
         Date:   Sat Sep 12 02:22:52 2009 -0300

                Initial commit



          README                                     | 243 ++
          Rakefile                                   |   10 +
          app/controllers/application_controller.rb |    10 +
          app/helpers/application_helper.rb          |    3 +
          config/boot.rb                             | 110 +
         ...
          test/performance/browsing_test.rb          |    9 +
          test/test_helper.rb                        |   38 +
          41 files changed, 8452 insertions(+), 0 deletions(-)




Saturday, September 12, 2009                                           24
Navegando pelo histórico
         $ git log -p --no-merges

         commit 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8
         Author: Celestino Gomes <celestino@HDU15121-ADIGITAL.local>
         Date:   Sat Sep 12 02:22:52 2009 -0300

                Initial commit

         diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb
         new file mode 100644
         index 0000000..4b60558
         --- /dev/null
         +++ b/test/performance/browsing_test.rb
         @@ -0,0 +1,9 @@
         +require 'test_helper'
         +require 'performance_test_help'
         +
         +# Profiling results for each test method are written to tmp/performance.
         +class BrowsingTest < ActionController::PerformanceTest
         + def test_homepage
         +    get '/'
         + end
         +end


Saturday, September 12, 2009                                                                  25
Navegando pelo histórico
   $ git log --pretty=oneline

   7f5a85113381e8c0d16e4679c4e5a81a4eb000b8 Initial commit

   $ git blame app/helpers/application_helper.rb

   ^7f5a851 (Celestino Gomes 2009-09-12 02:22:52 -0300 1) module ApplicationHelper
   ^7f5a851 (Celestino Gomes 2009-09-12 02:22:52 -0300 2) end




Saturday, September 12, 2009                                                         26
Manipulando o índice

       Remove do stage index

                  $ git reset [<commit>]

       Limpa os arquivos, inclusive os unstagged

                  $ git reset --hard [<commit>]
       Coloca os arquivos de volta para o stage index

                  $ git reset --soft [<commit>]

       Permite alterar o último commit

                  $ git commit --amend




Saturday, September 12, 2009                            27

<commit> - default HEAD
A diferença entre merge e rebase


                               master   sprint_branch



                                C1



                                C2          C4



                                C3          C5




Saturday, September 12, 2009                            28
A diferença entre merge e rebase

                       master      sprint_branch



                         C1
                                                   $ git checkout master
                                                   $ git pull . sprint_branch
                         C2            C4
                                                                 ou

                                                   $ git checkout master
                         C3            C5          $ git fetch
                                                   $ git merge sprint_branch


                         C6     merge commit




Saturday, September 12, 2009                                                    29
A diferença entre merge e rebase

                       master



                         C1
                                      $ git checkout master
                                      $ git pull --rebase . sprint_branch
                         C2     C4
                                                       ou

                                      $ git checkout master
                         C3     C5    $ git fetch
                                      $ git rebase sprint_branch


                        C4’     C5’




Saturday, September 12, 2009                                                30
Usando o stash


                                      $ git stash


                                   $ git stash list


                               $ git stash show stash@{0}


                                   $ git stash apply


                               $ git stash drop stash@{0}




Saturday, September 12, 2009                                31
Revertendo commits


                                $ git revert <commit_hash>


                               $ git revert -n <commit_hash>




Saturday, September 12, 2009                                   32

-n para deixar a reversão no index
Buscando por bugs


                                     $ git bisect start [<bad> [<good>]]


                                         $ git bisect good | bad [<rev>]


                                     $ git bisect skip [(<rev>|<range>)]


                                                       $ git bisect reset


                                         $ git bisect run <cmd | script>




Saturday, September 12, 2009                                                                                                                        33
1) Primeiro é necessário identificar pontos (commits) bons e ruins para começar a caça. Usar $ git log
2) $ git bisect run my_script - Note that the "run" script (my_script in the above example) should exit with code 0 in case the current source code is
good. Exit with a code between 1 and 127 (inclusive), except 125, if the current source code is bad.
Limpando a sujeira do dia-a-dia

       Remover arquivos/diretórios não trackeados
                    $ git clean -d -f



       Remover um branch remoto

                     $ git push origin :<branch_remoto>


       Limpar todo o stash

                    $ git stash clear




Saturday, September 12, 2009                                                                                                          34
clean para remover arquivos/diretórios não trackeados, push origin :<branch> limpa branches remotos, stash para limpar todo o stash
Funciona no Windows?

       • Somente através do cygwin ou msysGit




Saturday, September 12, 2009                    35
Referências

       • http://git.or.cz/gitwiki/GitDocumentation

       • http://www.kernel.org/pub/software/scm/git/docs/

       • http://blog.tinogomes.com/2008/05/11/instalando-e-usando-git-
         no-windows-xp/

       • http://github.com




Saturday, September 12, 2009                                             36
Perguntas




Saturday, September 12, 2009   37
Mais sobre mim




       • http://blog.tinogomes.com




Saturday, September 12, 2009         38
Obrigado!




Saturday, September 12, 2009   39

More Related Content

Similar to Git E Seu Amigo

Your first rails app - 2
 Your first rails app - 2 Your first rails app - 2
Your first rails app - 2Blazing Cloud
 
A jar-nORM-ous Task
A jar-nORM-ous TaskA jar-nORM-ous Task
A jar-nORM-ous TaskErin Dees
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyHiroshi SHIBATA
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Controlmobiledevnj
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlBecky Todd
 
Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyBlazing Cloud
 
浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編 浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編 Masakuni Kato
 
Virtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OO
Virtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OOVirtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OO
Virtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OOPaolo Cristofaro
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflowRiccardo Coppola
 
HOW TO BUILD GEMS #shibuyarb
HOW TO BUILD GEMS #shibuyarbHOW TO BUILD GEMS #shibuyarb
HOW TO BUILD GEMS #shibuyarbSATOSHI TAGOMORI
 
Webinar - Approaching 1 billion documents with MongoDB
Webinar - Approaching 1 billion documents with MongoDBWebinar - Approaching 1 billion documents with MongoDB
Webinar - Approaching 1 billion documents with MongoDBBoxed Ice
 
Coding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using FeaturesCoding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using FeaturesMyplanet Digital
 
OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...
OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...
OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...NETWAYS
 
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...JAX London
 
Rails 3 : Cool New Things
Rails 3 : Cool New ThingsRails 3 : Cool New Things
Rails 3 : Cool New ThingsY. Thong Kuah
 

Similar to Git E Seu Amigo (20)

Your first rails app - 2
 Your first rails app - 2 Your first rails app - 2
Your first rails app - 2
 
A jar-nORM-ous Task
A jar-nORM-ous TaskA jar-nORM-ous Task
A jar-nORM-ous Task
 
App Lego
App LegoApp Lego
App Lego
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Control
 
Barcamp PT
Barcamp PTBarcamp PT
Barcamp PT
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_many
 
浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編 浜松Rails3道場 其の弐 Model編
浜松Rails3道場 其の弐 Model編
 
Virtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OO
Virtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OOVirtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OO
Virtuoso RDF Triple Store Analysis Benchmark & mapping tools RDF / OO
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflow
 
HOW TO BUILD GEMS #shibuyarb
HOW TO BUILD GEMS #shibuyarbHOW TO BUILD GEMS #shibuyarb
HOW TO BUILD GEMS #shibuyarb
 
Webinar - Approaching 1 billion documents with MongoDB
Webinar - Approaching 1 billion documents with MongoDBWebinar - Approaching 1 billion documents with MongoDB
Webinar - Approaching 1 billion documents with MongoDB
 
Coding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using FeaturesCoding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using Features
 
OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...
OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...
OSMC 2008 | A large scale distributed Nagios installation for T-Systems Enter...
 
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
Rails 3 : Cool New Things
Rails 3 : Cool New ThingsRails 3 : Cool New Things
Rails 3 : Cool New Things
 

Recently uploaded

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Git E Seu Amigo

  • 1. Git é seu amigo Celestino Gomes Saturday, September 12, 2009 1
  • 2. O quê? • Criado em 2005 por Linus Torvalds • Necessidade, linux-kernel-devs • Originalmente, era um engine para VCS • Fluxo de trabalho distribuído • Prevenção de corrupção acidental • Alta performance Saturday, September 12, 2009 2
  • 3. Características básicas • Controle de versão distribuido (DVCS) • Gerenciamento de conteúdo e não arquivos • Branches como unidade de trabalho • SHA1 para associação e verificação • Staging index • Não é o subversion Saturday, September 12, 2009 3
  • 5. Diretório .git • Diretório .git na raíz de cada projeto • Arquivos de configuração (.git/config) • Index (.git/index) • Hooks (.git/hooks) • Object Database (.git/objects) • References (.git/refs) Saturday, September 12, 2009 5
  • 6. Object Database • Quatro tipos de objetos: • Blob, Tree, Commit e Tag • Todos registrados/gravados da mesma maneira Saturday, September 12, 2009 6
  • 7. Object Database - Loose format conteudo header + conteudo “2e6f9b0d5885b6010f9167787445617f553a735f” zlib(header + conteudo) .git/objects/2e/6f9b0d5885b6010f9167787445617f553a735f Saturday, September 12, 2009 7
  • 8. Object Database - Packed format .git/objects/2e/6f9b0d5885b6010f9167787445617f553a735f .git/objects/0b/772ec8eb9ae8952c3c1e56a9ffbe49385cc83a .git/objects/72/16b02627bc3d6ef57008f7ff67f0f8f13f488e git-gc .git/objects/pack/pack-0bc9a42eb66d7ae36bf44af8ff5a3888e8a02d12.idx .git/objects/pack/pack-0bc9a42eb66d7ae36bf44af8ff5a3888e8a02d12.pack Saturday, September 12, 2009 8 Digamos que os objetos listados referenciem o mesmo arquivo, com conjuntos pequenos de diferenças geradas ao longo do tempo. Usar uma ferramenta de manutenção (git-gc, por exemplo) vai compactar os objetos e armazená-los em ‘/pack’.
  • 9. Object Database - Blob Rakefile blob: 2e6f9b active_content.rb blob: 7034fe active_content_spec.rb blob: a738fc Saturday, September 12, 2009 9
  • 10. Object Database - Tree / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 10
  • 11. Object Database - Commit commit: 8d1ab4 / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 11
  • 12. Object Database - Commit commit: 8d1ab4 commit: 61db26 / tree: 1fba94 tree: 1fba94 Rakefile blob: 2e6f9b blob: 41d300 /lib tree: 3ef95a tree: 3ef95a active_content.rb blob: 7034fe blob: 7034fe /spec tree: 34ba74 tree: 34ba74 active_content_spec.rb blob: a738fc blob: 2a03fb Saturday, September 12, 2009 12
  • 13. Object Database - Tag tag: 6ee1f2 commit: 8d1ab4 / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 13
  • 14. Object Database - Resumindo Saturday, September 12, 2009 14
  • 15. Object Database - Resumo • Blob é o menor objeto do git • Tree contém Trees e Blobs • Commit contém Commits, Trees e Blobs • Tags contém/apontam um Commit Saturday, September 12, 2009 15
  • 16. References .git/refs/heads/master master HEAD commit: 8d1ab4 / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 16 Um branch é um ponteiro para um commit. Quando se avança um branch adicionando commits, o que está acontecendo, por baixo dos panos, é mudar o ponteiro do branch para um novo commit.
  • 17. Staging Index lib.rb Untracked $ git add lib.rb lib.rb Staged $ git commit -m “lib.rb” lib.rb Commited Saturday, September 12, 2009 17
  • 19. Criação de repositórios Criando um novo repositório $ rails my_blog ... $ cd my_blog $ git init $ git add . $ git commit -m “Initial commit” Criando um repositório a partir de um outro $ git clone git://github.com/tinogomes/my_blog_app_with_bug.git $ cd my_blog_app_with_bug $ git branch master Saturday, September 12, 2009 19
  • 20. Trabalhando em um branch remoto $ cd my_blog_app_with_bug $ git checkout -b refactoring origin/refactoring ... após modificações $ echo tmp > .gitignore $ git add . $ git commit -m “outras modificacoes” $ git pull $ git push origin refactoring Saturday, September 12, 2009 20
  • 21. Indo além do flow básico Saturday, September 12, 2009 21
  • 22. Adicionando arquivos $ git add <dir> $ git add <dir>/<arquivo> $ git add *.rb $ git add . (cuidado) Saturday, September 12, 2009 22
  • 23. Trabalhando com branch local $ cd my_blog_app_with_bug $ git branch meu_branch_local ... $ git checkout master $ git pull . master $ git push origim master $ git branch -d meu_branch_local Saturday, September 12, 2009 23
  • 24. Navegando pelo histórico $ git log --stat commit 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8 Author: Celestino Gomes <celestino@HDU15121-ADIGITAL.local> Date: Sat Sep 12 02:22:52 2009 -0300 Initial commit README | 243 ++ Rakefile | 10 + app/controllers/application_controller.rb | 10 + app/helpers/application_helper.rb | 3 + config/boot.rb | 110 + ... test/performance/browsing_test.rb | 9 + test/test_helper.rb | 38 + 41 files changed, 8452 insertions(+), 0 deletions(-) Saturday, September 12, 2009 24
  • 25. Navegando pelo histórico $ git log -p --no-merges commit 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8 Author: Celestino Gomes <celestino@HDU15121-ADIGITAL.local> Date: Sat Sep 12 02:22:52 2009 -0300 Initial commit diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb new file mode 100644 index 0000000..4b60558 --- /dev/null +++ b/test/performance/browsing_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' +require 'performance_test_help' + +# Profiling results for each test method are written to tmp/performance. +class BrowsingTest < ActionController::PerformanceTest + def test_homepage + get '/' + end +end Saturday, September 12, 2009 25
  • 26. Navegando pelo histórico $ git log --pretty=oneline 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8 Initial commit $ git blame app/helpers/application_helper.rb ^7f5a851 (Celestino Gomes 2009-09-12 02:22:52 -0300 1) module ApplicationHelper ^7f5a851 (Celestino Gomes 2009-09-12 02:22:52 -0300 2) end Saturday, September 12, 2009 26
  • 27. Manipulando o índice Remove do stage index $ git reset [<commit>] Limpa os arquivos, inclusive os unstagged $ git reset --hard [<commit>] Coloca os arquivos de volta para o stage index $ git reset --soft [<commit>] Permite alterar o último commit $ git commit --amend Saturday, September 12, 2009 27 <commit> - default HEAD
  • 28. A diferença entre merge e rebase master sprint_branch C1 C2 C4 C3 C5 Saturday, September 12, 2009 28
  • 29. A diferença entre merge e rebase master sprint_branch C1 $ git checkout master $ git pull . sprint_branch C2 C4 ou $ git checkout master C3 C5 $ git fetch $ git merge sprint_branch C6 merge commit Saturday, September 12, 2009 29
  • 30. A diferença entre merge e rebase master C1 $ git checkout master $ git pull --rebase . sprint_branch C2 C4 ou $ git checkout master C3 C5 $ git fetch $ git rebase sprint_branch C4’ C5’ Saturday, September 12, 2009 30
  • 31. Usando o stash $ git stash $ git stash list $ git stash show stash@{0} $ git stash apply $ git stash drop stash@{0} Saturday, September 12, 2009 31
  • 32. Revertendo commits $ git revert <commit_hash> $ git revert -n <commit_hash> Saturday, September 12, 2009 32 -n para deixar a reversão no index
  • 33. Buscando por bugs $ git bisect start [<bad> [<good>]] $ git bisect good | bad [<rev>] $ git bisect skip [(<rev>|<range>)] $ git bisect reset $ git bisect run <cmd | script> Saturday, September 12, 2009 33 1) Primeiro é necessário identificar pontos (commits) bons e ruins para começar a caça. Usar $ git log 2) $ git bisect run my_script - Note that the "run" script (my_script in the above example) should exit with code 0 in case the current source code is good. Exit with a code between 1 and 127 (inclusive), except 125, if the current source code is bad.
  • 34. Limpando a sujeira do dia-a-dia Remover arquivos/diretórios não trackeados $ git clean -d -f Remover um branch remoto $ git push origin :<branch_remoto> Limpar todo o stash $ git stash clear Saturday, September 12, 2009 34 clean para remover arquivos/diretórios não trackeados, push origin :<branch> limpa branches remotos, stash para limpar todo o stash
  • 35. Funciona no Windows? • Somente através do cygwin ou msysGit Saturday, September 12, 2009 35
  • 36. Referências • http://git.or.cz/gitwiki/GitDocumentation • http://www.kernel.org/pub/software/scm/git/docs/ • http://blog.tinogomes.com/2008/05/11/instalando-e-usando-git- no-windows-xp/ • http://github.com Saturday, September 12, 2009 36
  • 38. Mais sobre mim • http://blog.tinogomes.com Saturday, September 12, 2009 38