SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
GIT
workshop
usando Git desde 2008
O que é um SCM?
svn VS git
SVN

           it         svn
         m                u
    om                        pd
svnc                            ate
GIT

                             git
     ush                         pu
gi tp                               ll


           git push remote


           git pull remote
SVN :: CENTRALIZADO
Workflow - Repositório Central
svn
                Desenvolvimento Linear

               Renomear arquivo/pasta dói

desvantagens        Repos Grandes

                 Resolução de Conflitos
                           ....
git   svn
“Git is a stupid content tracker.”
                          (Peepcode Git Internals)




git
git != github
Social Coding




                        Free para projetos Open Source


http://www.github.com
                           Firewall para “enterprise”
Ágil


  git              Autonomia


vantagens   Repositórios Independentes

              Resolução de conflitos

              Repositórios Pequenos
git           Quebra de paradigma


desvantagens     Curva de Aprendizado
                           t

               Necessário ter um processo
                        definido
curiosidade

The Ruby on Rails Git repository download, which
includes the full history of the project – every
version of every file, weighs in at around 13M, which
is not even twice the size of a single checkout of the
project (~9M). The Subversion server repository for
the same project is about 115M.




                                            Peepcode Git internals página 12
Controle
de versões distribuído
Necessário ter um processo
                          definido


Workflow - Repositório Central
Necessário ter um processo
                           definido


Workflow - Gerente de Integração
era uma vez ...
 Você está sentado em sua mesa trabalhando em
uma estória. De repente, sua SM chega perto de você
 e pede para você parar o que você está fazendo, pois
      foi encontrado um bug show stopper.
http://www.google.com.br/imgres?start=116&um=1&hl=pt-BR&biw=1280&bih=636&tbm=isch&tbnid=6fTHDZKMmPElhM:&imgrefurl=http://www.clear-lines.com/
 blog/post/Automatically-exclude-bin-and-obj-folder-in-Tortoise-SVN.aspx&docid=OHbeiJsJUJ8saM&imgurl=http://www.clear-lines.com/blog/image.axd%253Fpicture
%253DAddFiles_thumb.png&w=387&h=433&ei=KgqFT82RBqr40gHv4djbBw&zoom=1&iact=hc&vpx=665&vpy=279&dur=306&hovh=149&hovw=133&tx=122&ty=
                            109&sig=105001613950035108112&page=6&tbnh=140&tbnw=125&ndsp=23&ved=1t:429,r:9,s:116,i:104
resolvendo o problema
Comitar as alterações
                   (sem terminar a task)



  svn           Qual o dev que está com o
                     ambiente limpo?
                      Encontrar o bug;
Quanto tempo         Implementar o fix;
               Remover as changes anteriores;
   levaria?            Comitar o fix;
                Voltar alterações da change.
                       Criar branch;
                      Comitar changes;
                     Voltar no trunk; (?)
                        Comitar fix..
git                             Criar Branch

                          Colocar changes no ‘stash’




            Quanto tempo
               levaria?

Git permite que o desenvolvedor seja mais ágil!
filosofia                    Só código que funciona no master

                                     Feature Branch (*)

                             “Commit all the fucking time”




  “Eu não gosto de resolver conflito!”
                                                     (aleal)

     (*) http://martinfowler.com/bliki/FeatureBranch.html
Commit early,
Commit often

Never Commit
 broken code
Mão na massa


http://www.flickr.com/photos/traftery/4773457853/
Configurando e Commit
# Configurando conta do usuário;
$	
  git	
  config	
  -­‐-­‐global	
  user.name	
  "Alberto	
  Leal"

$	
  git	
  config	
  -­‐-­‐global	
  user.email	
  albertonb@gmail.com

$	
  git	
  config	
  -­‐-­‐global	
  color.ui	
  auto


# Criando estrutura de pastas do projeto e adicionando alguns arquivos;
$	
  mkdir	
  ~/meu_projeto

$	
  cd	
  ~/meu_projeto

$	
  touch	
  README.txt	
  config.txt

	
  	
  
# Iniciando um repositório git;
$	
  git	
  init
Initialized	
  empty	
  Git	
  repository	
  in	
  ~/meu_projeto/.git/
Configurando e Commit
# Interagindo com o repositório criado;
$	
  git	
  status
#	
  On	
  branch	
  master
#
#	
  Initial	
  commit
#
#	
  Untracked	
  files:
#	
  	
  	
  (use	
  "git	
  add	
  <file>..."	
  to	
  include	
  in	
  what	
  will	
  be	
  committed)
#
#	
   README.txt
#	
   config.txt
nothing	
  added	
  to	
  commit	
  but	
  untracked	
  files	
  present	
  (use	
  "git	
  add"	
  to	
  track)

$	
  git	
  add	
  .
$	
  git	
  status
#	
  On	
  branch	
  master
#
#	
  Initial	
  commit
#
#	
  Changes	
  to	
  be	
  committed:
#	
  	
  	
  (use	
  "git	
  rm	
  -­‐-­‐cached	
  <file>..."	
  to	
  unstage)
#
#	
   new	
  file:	
  	
  	
  README.txt
#	
   new	
  file:	
  	
  	
  config.txt
Configurando e Commit
# Criando o primeiro commit;
$	
  git	
  commit	
  -­‐m	
  “Initial	
  Commit”
[master	
  (root-­‐commit)	
  4692340]	
  Initial	
  Commit
	
  0	
  files	
  changed,	
  0	
  insertions(+),	
  0	
  deletions(-­‐)
	
  create	
  mode	
  100644	
  README.txt
	
  create	
  mode	
  100644	
  config.txt

$	
  git	
  log
commit	
  4692340f4f326a4120337185474153e65c808cd1
Author:	
  Alberto	
  Leal	
  <albertonb@gmail.com>
Date:	
  	
  	
  Sun	
  Mar	
  25	
  19:13:59	
  2012	
  -­‐0300

	
  	
  	
  	
  Initial	
  Commit
O que é um commit?                            Curva de Aprendizado

                                               Quebra de paradigma
       tag   v1.0




                    sha1:	
  4692340f4f326a4120337185474153e65c808cd1

      Commit
       Tree



                          Blob
O que é um commit?      Curva de Aprendizado



        Commit       Commit
        (abcde)       (fghijl)



        /public      /public



       index.html        index.html

                        whoami.html
Curva de Aprendizado




Working Directory
   Stage area
  Repository
Diff e Revertendo Commit
# Abra o arquivo README.txt e altere o conteúdo;
$	
  git	
  status
#	
  On	
  branch	
  master
#	
  Changed	
  but	
  not	
  updated:
#	
  	
  	
  (use	
  "git	
  add	
  <file>..."	
  to	
  update	
  what	
  will	
  be	
  committed)
#	
  	
  	
  (use	
  "git	
  checkout	
  -­‐-­‐	
  <file>..."	
  to	
  discard	
  changes	
  in	
  working	
  directory)
#
#	
   modified:	
  	
  	
  README.txt
#
no	
  changes	
  added	
  to	
  commit	
  (use	
  "git	
  add"	
  and/or	
  "git	
  commit	
  -­‐a")


$	
  git	
  diff
diff	
  -­‐-­‐git	
  a/README.txt	
  b/README.txt
index	
  87147e2..3468b97	
  100644
-­‐-­‐-­‐	
  a/README.txt
+++	
  b/README.txt
@@	
  -­‐1	
  +1,3	
  @@
-­‐This	
  is	
  a	
  simple	
  document.
	
  No	
  newline	
  at	
  end	
  of	
  file
+Este	
  é	
  um	
  documento	
  simples.
+
+Estamos	
  dando	
  uma	
  olhada	
  no	
  Git.
	
  No	
  newline	
  at	
  end	
  of	
  file
Diff e Revertendo Commit
# Para cancelar todas as modificações abaixo, basta dar um checkout no arquivo do repo;
$	
  git	
  checkout	
  README.txt	
  

$	
  git	
  status
#	
  On	
  branch	
  master
nothing	
  to	
  commit	
  (working	
  directory	
  clean)


# Caso você tenha comitado as alterações feitas anteriormente, para reverter o commit, faça;
$	
  git	
  log	
  
commit	
  23a7e65d7353bd61935c627b13cad8890eea0de6
Author:	
  Alberto	
  Leal	
  <albertonb@gmail.com>
Date:	
  	
  	
  Wed	
  Apr	
  11	
  21:10:19	
  2012	
  -­‐0300

	
  	
  	
  	
  Adding	
  some	
  lines

commit	
  909f2bbfc158b41619e90ea7679f3eb11dd46896
Author:	
  Alberto	
  Leal	
  <albertonb@gmail.com>
Date:	
  	
  	
  Wed	
  Apr	
  11	
  21:03:34	
  2012	
  -­‐0300

	
  	
  	
  	
  Initial	
  Commit

$	
  git	
  revert	
  23a7e65d7353bd
Diff e Revertendo Commit
$	
  git	
  log	
  

commit	
  143059e977ea838b78c054d37f03a82f82051a7b
Author:	
  Alberto	
  Leal	
  <albertonb@gmail.com>
Date:	
  	
  	
  Wed	
  Apr	
  11	
  21:11:13	
  2012	
  -­‐0300

	
  	
  	
  	
  Revert	
  "Adding	
  some	
  lines"
	
  	
  	
  	
  
	
  	
  	
  	
  This	
  reverts	
  commit	
  23a7e65d7353bd61935c627b13cad8890eea0de6.

commit	
  23a7e65d7353bd61935c627b13cad8890eea0de6
Author:	
  Alberto	
  Leal	
  <albertonb@gmail.com>
Date:	
  	
  	
  Wed	
  Apr	
  11	
  21:10:19	
  2012	
  -­‐0300

	
  	
  	
  	
  Adding	
  some	
  lines

commit	
  909f2bbfc158b41619e90ea7679f3eb11dd46896
Author:	
  Alberto	
  Leal	
  <albertonb@gmail.com>
Date:	
  	
  	
  Wed	
  Apr	
  11	
  21:03:34	
  2012	
  -­‐0300

	
  	
  	
  	
  Initial	
  Commit
Criar Branch
Branch
$	
  git	
  branch	
  
*	
  master

$	
  git	
  branch	
  
*	
  master

$	
  git	
  branch	
  new_feature
$	
  git	
  branch
*	
  master
	
  	
  new_feature

$	
  git	
  checkout	
  -­‐b	
  another_feature
Switched	
  to	
  a	
  new	
  branch	
  'another_feature'

$	
  git	
  branch
*	
  another_feature
	
  	
  master
	
  	
  new_feature
Criar Branch
Branch
$	
  touch	
  a.txt	
  b.txt	
  c.txt	
  d.txt	
  e.txt

$	
  git	
  status	
  
#	
  On	
  branch	
  another_feature
#	
  Untracked	
  files:
#	
  	
  	
  (use	
  "git	
  add	
  <file>..."	
  to	
  include	
  in	
  what	
  will	
  be	
  committed)
#
#	
   a.txt
#	
   b.txt
#	
   c.txt
#	
   d.txt
#	
   e.txt
nothing	
  added	
  to	
  commit	
  but	
  untracked	
  files	
  present	
  (use	
  "git	
  add"	
  to	
  track)

$	
  git	
  add	
  .	
  &&	
  git	
  commit	
  -­‐m	
  "Adding	
  new	
  files"
[another_feature	
  08f9fbe]	
  Adding	
  new	
  files
	
  0	
  files	
  changed,	
  0	
  insertions(+),	
  0	
  deletions(-­‐)
	
  create	
  mode	
  100644	
  a.txt
	
  create	
  mode	
  100644	
  b.txt
	
  create	
  mode	
  100644	
  c.txt
	
  create	
  mode	
  100644	
  d.txt
	
  create	
  mode	
  100644	
  e.txt

$	
  git	
  checkout	
  new_feature
$	
  ls
README	
   	
   alberto.txt	
   oi.txt	
   	
             ola.txt
lembra ...?
 Você está sentado em sua mesa trabalhando em
uma estória. De repente, sua SM chega perto de você
 e pede para você parar o que você está fazendo, pois
      foi encontrado um bug show stopper.
Colocar changes no ‘stash’
Stash
$	
  git	
  checkout	
  another_feature
$	
  ls
README	
   	
   alberto.txt	
   c.txt	
   	
   e.txt	
   	
              ola.txt
a.txt	
   	
   b.txt	
   	
   d.txt	
   	
   oi.txt

$	
  git	
  status
#	
  On	
  branch	
  another_feature
#	
  Changed	
  but	
  not	
  updated:
#	
  	
  	
  (use	
  "git	
  add	
  <file>..."	
  to	
  update	
  what	
  will	
  be	
  committed)
#	
  	
  	
  (use	
  "git	
  checkout	
  -­‐-­‐	
  <file>..."	
  to	
  discard	
  changes	
  in	
  working	
  directory)
#
#	
   modified:	
  	
  	
  a.txt
#	
   modified:	
  	
  	
  b.txt
#	
   modified:	
  	
  	
  c.txt
#	
   modified:	
  	
  	
  d.txt
#	
   modified:	
  	
  	
  e.txt
#
no	
  changes	
  added	
  to	
  commit	
  (use	
  "git	
  add"	
  and/or	
  "git	
  commit	
  -­‐a")

$	
  git	
  stash	
  save	
  login_with_ajax
Saved	
  working	
  directory	
  and	
  index	
  state	
  On	
  another_feature:	
  login_with_ajax
HEAD	
  is	
  now	
  at	
  08f9fbe	
  Adding	
  new	
  files

$	
  git	
  status
#	
  On	
  branch	
  another_feature
nothing	
  to	
  commit	
  (working	
  directory	
  clean)
Colocar changes no ‘stash’
Stash
$	
  git	
  stash	
  list
stash@{0}:	
  On	
  another_feature:	
  login_with_ajax

$	
  git	
  stash	
  apply	
  stash@{0}
#	
  On	
  branch	
  another_feature
#	
  Changed	
  but	
  not	
  updated:
#	
  	
  	
  (use	
  "git	
  add	
  <file>..."	
  to	
  update	
  what	
  will	
  be	
  committed)
#	
  	
  	
  (use	
  "git	
  checkout	
  -­‐-­‐	
  <file>..."	
  to	
  discard	
  changes	
  in	
  working	
  directory)
#
#	
   modified:	
  	
  	
  a.txt
#	
   modified:	
  	
  	
  b.txt
#	
   modified:	
  	
  	
  c.txt
#	
   modified:	
  	
  	
  d.txt
#	
   modified:	
  	
  	
  e.txt
#
no	
  changes	
  added	
  to	
  commit	
  (use	
  "git	
  add"	
  and/or	
  "git	
  commit	
  -­‐a")
Resolução de conflitos
Resolvendo conflitos
 $	
  git	
  checkout	
  master

 $	
  git	
  status	
  
 #	
  On	
  branch	
  master
 nothing	
  to	
  commit	
  (working	
  directory	
  clean)

 $	
  touch	
  a.txt	
  &&	
  echo	
  "Workshop	
  de	
  Git"	
  >	
  a.txt
 $	
  git	
  add	
  .
 $	
  git	
  commit	
  -­‐m	
  “Adding	
  new	
  file	
  a”
 [master	
  e88ac64]	
  Adding	
  file	
  ad
 	
  1	
  files	
  changed,	
  1	
  insertions(+),	
  0	
  deletions(-­‐)
 	
  create	
  mode	
  100644	
  a.txt

 $	
  git	
  checkout	
  another_feature
 Switched	
  to	
  a	
  new	
  branch	
  'another_feature'

 $	
  echo	
  "CI&T	
  apresenta	
  Workshop	
  de	
  Git"	
  >	
  a.txt

 $	
  git	
  commit	
  -­‐am	
  "Changing	
  on	
  file	
  a"
 [another_feature	
  d7a6544]	
  Changing	
  on	
  file	
  a
 	
  1	
  files	
  changed,	
  1	
  insertions(+),	
  1	
  deletions(-­‐)

 $	
  git	
  checkout	
  master
 Switched	
  to	
  branch	
  'master'
Resolução de conflitos
Resolvendo conflitos
 $	
  git	
  merge	
  another_feature
 Auto-­‐merging	
  a.txt
 CONFLICT	
  (add/add):	
  Merge	
  conflict	
  in	
  a.txt
 Automatic	
  merge	
  failed;	
  fix	
  conflicts	
  and	
  then	
  commit	
  the	
  result.

 $	
  git	
  diff
 diff	
  -­‐-­‐cc	
  a.txt
 index	
  f4e2830,ae35584..0000000
 -­‐-­‐-­‐	
  a/a.txt
 +++	
  b/a.txt
 @@@	
  -­‐1,1	
  -­‐1,1	
  +1,5	
  @@@
 -­‐	
  Workshop	
  de	
  Git
 	
  -­‐Cit	
  apresenta	
  workshop	
  de	
  git.
 ++<<<<<<<	
  HEAD
 ++Workshop	
  de	
  Git
 ++=======
 ++Cit	
  apresenta	
  workshop	
  de	
  git.
 ++>>>>>>>	
  another_feature

 $	
  git	
  commit	
  -­‐am	
  "Merging	
  branches"
 [master	
  36e2a5d]	
  Merging	
  branches

 $	
  git	
  log
 commit	
  36e2a5d1b4cdc74d967ced02a29190321adefbec
 Merge:	
  e88ac64	
  d7a6544
 Author:	
  Alberto	
  Leal	
  <albertonb@gmail.com>
 Date:	
  	
  	
  Wed	
  Apr	
  11	
  22:00:50	
  2012	
  -­‐0300
 	
  	
  	
  	
  Merging	
  branches
Procurando bug com git bisect
http://imasters.com.br/artigo/15310/desenvolvimento/git-localizando-a-origem-de-um-bug-atraves-de-busca-
                                        binaria-entre-os-commits
QUEM USA?
•Linux Kernel       •jQuery
•Git                •node.js
•Perl               •Redis
•PHP                •CakePHP
•Eclipse            •mongodb
•Gnome              •...
•KDE
•Ruby on Rails
•Android
•PostgreSQL
•Debian
•X.org
FERRAMENTAS
•Github
•Gitorious
•SmartGit
•Tortoise
•...
INSTALANDO GIT

Ubuntu
sudo apt-get install git-core git-doc git-svn git-gui gitk ssh


Windows
http://msysgit.github.com/
OBRIGADO!!
           aleal@ciandt.com

http://www.albertoleal.eti.br/category/git
adesivos na minha mesa

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Git and git hub
Git and git hubGit and git hub
Git and git hub
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Working with Git
Working with GitWorking with Git
Working with Git
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Git Basic
Git BasicGit Basic
Git Basic
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git internals
Git internalsGit internals
Git internals
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 

Andere mochten auch

Utilizando Git em Projetos Com Repositório Centralizado
Utilizando Git em Projetos Com Repositório CentralizadoUtilizando Git em Projetos Com Repositório Centralizado
Utilizando Git em Projetos Com Repositório CentralizadoAlberto Leal
 
IBM - Apresentando jQuery
IBM - Apresentando jQueryIBM - Apresentando jQuery
IBM - Apresentando jQueryAlberto Leal
 
Contribuindo com a comunidade Open Source
Contribuindo com a comunidade Open SourceContribuindo com a comunidade Open Source
Contribuindo com a comunidade Open SourceAlberto Leal
 
Testing Services Effectively
Testing Services Effectively Testing Services Effectively
Testing Services Effectively Alberto Leal
 
Guru-Campinas - Continuous integration
Guru-Campinas - Continuous integrationGuru-Campinas - Continuous integration
Guru-Campinas - Continuous integrationAlberto Leal
 
Designing the APIs for an internal set of services
Designing the APIs for an internal set of servicesDesigning the APIs for an internal set of services
Designing the APIs for an internal set of servicesAlberto Leal
 

Andere mochten auch (7)

Utilizando Git em Projetos Com Repositório Centralizado
Utilizando Git em Projetos Com Repositório CentralizadoUtilizando Git em Projetos Com Repositório Centralizado
Utilizando Git em Projetos Com Repositório Centralizado
 
IBM - Apresentando jQuery
IBM - Apresentando jQueryIBM - Apresentando jQuery
IBM - Apresentando jQuery
 
O que é dojo
O que é dojoO que é dojo
O que é dojo
 
Contribuindo com a comunidade Open Source
Contribuindo com a comunidade Open SourceContribuindo com a comunidade Open Source
Contribuindo com a comunidade Open Source
 
Testing Services Effectively
Testing Services Effectively Testing Services Effectively
Testing Services Effectively
 
Guru-Campinas - Continuous integration
Guru-Campinas - Continuous integrationGuru-Campinas - Continuous integration
Guru-Campinas - Continuous integration
 
Designing the APIs for an internal set of services
Designing the APIs for an internal set of servicesDesigning the APIs for an internal set of services
Designing the APIs for an internal set of services
 

Ähnlich wie Wokshop de Git

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitRick Umali
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierChristoph Matthies
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in UnityRifauddin Tsalitsy
 

Ähnlich wie Wokshop de Git (20)

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git github
Git githubGit github
Git github
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Gittalk
GittalkGittalk
Gittalk
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Loading...git
Loading...gitLoading...git
Loading...git
 
3 Git
3 Git3 Git
3 Git
 
Git
GitGit
Git
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 
simple Git
simple Git simple Git
simple Git
 
Git
GitGit
Git
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
 
M.Mozūras - git
M.Mozūras - gitM.Mozūras - git
M.Mozūras - git
 

Kürzlich hochgeladen

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Kürzlich hochgeladen (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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.
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Wokshop de Git

  • 3. O que é um SCM?
  • 5. SVN it svn m u om pd svnc ate
  • 6. GIT git ush pu gi tp ll git push remote git pull remote
  • 7. SVN :: CENTRALIZADO Workflow - Repositório Central
  • 8. svn Desenvolvimento Linear Renomear arquivo/pasta dói desvantagens Repos Grandes Resolução de Conflitos ....
  • 9. git svn
  • 10. “Git is a stupid content tracker.” (Peepcode Git Internals) git
  • 12. Social Coding Free para projetos Open Source http://www.github.com Firewall para “enterprise”
  • 13. Ágil git Autonomia vantagens Repositórios Independentes Resolução de conflitos Repositórios Pequenos
  • 14. git Quebra de paradigma desvantagens Curva de Aprendizado t Necessário ter um processo definido
  • 15. curiosidade The Ruby on Rails Git repository download, which includes the full history of the project – every version of every file, weighs in at around 13M, which is not even twice the size of a single checkout of the project (~9M). The Subversion server repository for the same project is about 115M. Peepcode Git internals página 12
  • 17. Necessário ter um processo definido Workflow - Repositório Central
  • 18. Necessário ter um processo definido Workflow - Gerente de Integração
  • 19. era uma vez ... Você está sentado em sua mesa trabalhando em uma estória. De repente, sua SM chega perto de você e pede para você parar o que você está fazendo, pois foi encontrado um bug show stopper.
  • 22. Comitar as alterações (sem terminar a task) svn Qual o dev que está com o ambiente limpo? Encontrar o bug; Quanto tempo Implementar o fix; Remover as changes anteriores; levaria? Comitar o fix; Voltar alterações da change. Criar branch; Comitar changes; Voltar no trunk; (?) Comitar fix..
  • 23. git Criar Branch Colocar changes no ‘stash’ Quanto tempo levaria? Git permite que o desenvolvedor seja mais ágil!
  • 24. filosofia Só código que funciona no master Feature Branch (*) “Commit all the fucking time” “Eu não gosto de resolver conflito!” (aleal) (*) http://martinfowler.com/bliki/FeatureBranch.html
  • 25. Commit early, Commit often Never Commit broken code
  • 27. Configurando e Commit # Configurando conta do usuário; $  git  config  -­‐-­‐global  user.name  "Alberto  Leal" $  git  config  -­‐-­‐global  user.email  albertonb@gmail.com $  git  config  -­‐-­‐global  color.ui  auto # Criando estrutura de pastas do projeto e adicionando alguns arquivos; $  mkdir  ~/meu_projeto $  cd  ~/meu_projeto $  touch  README.txt  config.txt     # Iniciando um repositório git; $  git  init Initialized  empty  Git  repository  in  ~/meu_projeto/.git/
  • 28. Configurando e Commit # Interagindo com o repositório criado; $  git  status #  On  branch  master # #  Initial  commit # #  Untracked  files: #      (use  "git  add  <file>..."  to  include  in  what  will  be  committed) # #   README.txt #   config.txt nothing  added  to  commit  but  untracked  files  present  (use  "git  add"  to  track) $  git  add  . $  git  status #  On  branch  master # #  Initial  commit # #  Changes  to  be  committed: #      (use  "git  rm  -­‐-­‐cached  <file>..."  to  unstage) # #   new  file:      README.txt #   new  file:      config.txt
  • 29. Configurando e Commit # Criando o primeiro commit; $  git  commit  -­‐m  “Initial  Commit” [master  (root-­‐commit)  4692340]  Initial  Commit  0  files  changed,  0  insertions(+),  0  deletions(-­‐)  create  mode  100644  README.txt  create  mode  100644  config.txt $  git  log commit  4692340f4f326a4120337185474153e65c808cd1 Author:  Alberto  Leal  <albertonb@gmail.com> Date:      Sun  Mar  25  19:13:59  2012  -­‐0300        Initial  Commit
  • 30. O que é um commit? Curva de Aprendizado Quebra de paradigma tag v1.0 sha1:  4692340f4f326a4120337185474153e65c808cd1 Commit Tree Blob
  • 31. O que é um commit? Curva de Aprendizado Commit Commit (abcde) (fghijl) /public /public index.html index.html whoami.html
  • 32. Curva de Aprendizado Working Directory Stage area Repository
  • 33. Diff e Revertendo Commit # Abra o arquivo README.txt e altere o conteúdo; $  git  status #  On  branch  master #  Changed  but  not  updated: #      (use  "git  add  <file>..."  to  update  what  will  be  committed) #      (use  "git  checkout  -­‐-­‐  <file>..."  to  discard  changes  in  working  directory) # #   modified:      README.txt # no  changes  added  to  commit  (use  "git  add"  and/or  "git  commit  -­‐a") $  git  diff diff  -­‐-­‐git  a/README.txt  b/README.txt index  87147e2..3468b97  100644 -­‐-­‐-­‐  a/README.txt +++  b/README.txt @@  -­‐1  +1,3  @@ -­‐This  is  a  simple  document.  No  newline  at  end  of  file +Este  é  um  documento  simples. + +Estamos  dando  uma  olhada  no  Git.  No  newline  at  end  of  file
  • 34. Diff e Revertendo Commit # Para cancelar todas as modificações abaixo, basta dar um checkout no arquivo do repo; $  git  checkout  README.txt   $  git  status #  On  branch  master nothing  to  commit  (working  directory  clean) # Caso você tenha comitado as alterações feitas anteriormente, para reverter o commit, faça; $  git  log   commit  23a7e65d7353bd61935c627b13cad8890eea0de6 Author:  Alberto  Leal  <albertonb@gmail.com> Date:      Wed  Apr  11  21:10:19  2012  -­‐0300        Adding  some  lines commit  909f2bbfc158b41619e90ea7679f3eb11dd46896 Author:  Alberto  Leal  <albertonb@gmail.com> Date:      Wed  Apr  11  21:03:34  2012  -­‐0300        Initial  Commit $  git  revert  23a7e65d7353bd
  • 35. Diff e Revertendo Commit $  git  log   commit  143059e977ea838b78c054d37f03a82f82051a7b Author:  Alberto  Leal  <albertonb@gmail.com> Date:      Wed  Apr  11  21:11:13  2012  -­‐0300        Revert  "Adding  some  lines"                This  reverts  commit  23a7e65d7353bd61935c627b13cad8890eea0de6. commit  23a7e65d7353bd61935c627b13cad8890eea0de6 Author:  Alberto  Leal  <albertonb@gmail.com> Date:      Wed  Apr  11  21:10:19  2012  -­‐0300        Adding  some  lines commit  909f2bbfc158b41619e90ea7679f3eb11dd46896 Author:  Alberto  Leal  <albertonb@gmail.com> Date:      Wed  Apr  11  21:03:34  2012  -­‐0300        Initial  Commit
  • 36. Criar Branch Branch $  git  branch   *  master $  git  branch   *  master $  git  branch  new_feature $  git  branch *  master    new_feature $  git  checkout  -­‐b  another_feature Switched  to  a  new  branch  'another_feature' $  git  branch *  another_feature    master    new_feature
  • 37. Criar Branch Branch $  touch  a.txt  b.txt  c.txt  d.txt  e.txt $  git  status   #  On  branch  another_feature #  Untracked  files: #      (use  "git  add  <file>..."  to  include  in  what  will  be  committed) # #   a.txt #   b.txt #   c.txt #   d.txt #   e.txt nothing  added  to  commit  but  untracked  files  present  (use  "git  add"  to  track) $  git  add  .  &&  git  commit  -­‐m  "Adding  new  files" [another_feature  08f9fbe]  Adding  new  files  0  files  changed,  0  insertions(+),  0  deletions(-­‐)  create  mode  100644  a.txt  create  mode  100644  b.txt  create  mode  100644  c.txt  create  mode  100644  d.txt  create  mode  100644  e.txt $  git  checkout  new_feature $  ls README     alberto.txt   oi.txt     ola.txt
  • 38. lembra ...? Você está sentado em sua mesa trabalhando em uma estória. De repente, sua SM chega perto de você e pede para você parar o que você está fazendo, pois foi encontrado um bug show stopper.
  • 39. Colocar changes no ‘stash’ Stash $  git  checkout  another_feature $  ls README     alberto.txt   c.txt     e.txt     ola.txt a.txt     b.txt     d.txt     oi.txt $  git  status #  On  branch  another_feature #  Changed  but  not  updated: #      (use  "git  add  <file>..."  to  update  what  will  be  committed) #      (use  "git  checkout  -­‐-­‐  <file>..."  to  discard  changes  in  working  directory) # #   modified:      a.txt #   modified:      b.txt #   modified:      c.txt #   modified:      d.txt #   modified:      e.txt # no  changes  added  to  commit  (use  "git  add"  and/or  "git  commit  -­‐a") $  git  stash  save  login_with_ajax Saved  working  directory  and  index  state  On  another_feature:  login_with_ajax HEAD  is  now  at  08f9fbe  Adding  new  files $  git  status #  On  branch  another_feature nothing  to  commit  (working  directory  clean)
  • 40. Colocar changes no ‘stash’ Stash $  git  stash  list stash@{0}:  On  another_feature:  login_with_ajax $  git  stash  apply  stash@{0} #  On  branch  another_feature #  Changed  but  not  updated: #      (use  "git  add  <file>..."  to  update  what  will  be  committed) #      (use  "git  checkout  -­‐-­‐  <file>..."  to  discard  changes  in  working  directory) # #   modified:      a.txt #   modified:      b.txt #   modified:      c.txt #   modified:      d.txt #   modified:      e.txt # no  changes  added  to  commit  (use  "git  add"  and/or  "git  commit  -­‐a")
  • 41. Resolução de conflitos Resolvendo conflitos $  git  checkout  master $  git  status   #  On  branch  master nothing  to  commit  (working  directory  clean) $  touch  a.txt  &&  echo  "Workshop  de  Git"  >  a.txt $  git  add  . $  git  commit  -­‐m  “Adding  new  file  a” [master  e88ac64]  Adding  file  ad  1  files  changed,  1  insertions(+),  0  deletions(-­‐)  create  mode  100644  a.txt $  git  checkout  another_feature Switched  to  a  new  branch  'another_feature' $  echo  "CI&T  apresenta  Workshop  de  Git"  >  a.txt $  git  commit  -­‐am  "Changing  on  file  a" [another_feature  d7a6544]  Changing  on  file  a  1  files  changed,  1  insertions(+),  1  deletions(-­‐) $  git  checkout  master Switched  to  branch  'master'
  • 42. Resolução de conflitos Resolvendo conflitos $  git  merge  another_feature Auto-­‐merging  a.txt CONFLICT  (add/add):  Merge  conflict  in  a.txt Automatic  merge  failed;  fix  conflicts  and  then  commit  the  result. $  git  diff diff  -­‐-­‐cc  a.txt index  f4e2830,ae35584..0000000 -­‐-­‐-­‐  a/a.txt +++  b/a.txt @@@  -­‐1,1  -­‐1,1  +1,5  @@@ -­‐  Workshop  de  Git  -­‐Cit  apresenta  workshop  de  git. ++<<<<<<<  HEAD ++Workshop  de  Git ++======= ++Cit  apresenta  workshop  de  git. ++>>>>>>>  another_feature $  git  commit  -­‐am  "Merging  branches" [master  36e2a5d]  Merging  branches $  git  log commit  36e2a5d1b4cdc74d967ced02a29190321adefbec Merge:  e88ac64  d7a6544 Author:  Alberto  Leal  <albertonb@gmail.com> Date:      Wed  Apr  11  22:00:50  2012  -­‐0300        Merging  branches
  • 43. Procurando bug com git bisect http://imasters.com.br/artigo/15310/desenvolvimento/git-localizando-a-origem-de-um-bug-atraves-de-busca- binaria-entre-os-commits
  • 44. QUEM USA? •Linux Kernel •jQuery •Git •node.js •Perl •Redis •PHP •CakePHP •Eclipse •mongodb •Gnome •... •KDE •Ruby on Rails •Android •PostgreSQL •Debian •X.org
  • 46. INSTALANDO GIT Ubuntu sudo apt-get install git-core git-doc git-svn git-gui gitk ssh Windows http://msysgit.github.com/
  • 47. OBRIGADO!! aleal@ciandt.com http://www.albertoleal.eti.br/category/git