Wokshop de Git
-
Upload
alberto-leal -
Category
Technology
-
view
612 -
download
0
description
Transcript of Wokshop de Git
![Page 1: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/1.jpg)
GITworkshop
![Page 2: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/2.jpg)
usando Git desde 2008
![Page 3: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/3.jpg)
O que é um SCM?
![Page 4: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/4.jpg)
svn VS git
![Page 5: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/5.jpg)
SVN
svn co
mmit svn update
![Page 6: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/6.jpg)
GIT
git push git pull
git push remote
git pull remote
![Page 7: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/7.jpg)
SVN :: CENTRALIZADOWorkflow - Repositório Central
![Page 8: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/8.jpg)
desvantagens
svnDesenvolvimento Linear
Renomear arquivo/pasta dói
Repos Grandes
....
Resolução de Conflitos
![Page 9: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/9.jpg)
git svn
![Page 10: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/10.jpg)
git
“Git is a stupid content tracker.”(Peepcode Git Internals)
![Page 11: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/11.jpg)
git github!=
![Page 12: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/12.jpg)
Social Coding
Free para projetos Open Source
Firewall para “enterprise”
http://www.github.com
![Page 13: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/13.jpg)
vantagens
Autonomia
Ágil
Repositórios Independentes
Resolução de conflitos
Repositórios Pequenos
git
![Page 14: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/14.jpg)
desvantagens
gittCurva de Aprendizado
Quebra de paradigma
Necessário ter um processo definido
![Page 15: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/15.jpg)
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
curiosidade
![Page 16: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/16.jpg)
Controle de versões distribuído
![Page 17: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/17.jpg)
Workflow - Repositório Central
Necessário ter um processo definido
![Page 18: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/18.jpg)
Workflow - Gerente de Integração
Necessário ter um processo definido
![Page 19: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/19.jpg)
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.
era uma vez ...
![Page 20: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/20.jpg)
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
![Page 21: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/21.jpg)
resolvendo o problema
![Page 22: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/22.jpg)
Qual o dev que está com o ambiente limpo?
Comitar as alterações (sem terminar a task)
Encontrar o bug;Implementar o fix;
Remover as changes anteriores;Comitar o fix;
Voltar alterações da change.
Criar branch;Comitar changes;Voltar no trunk; (?)
Comitar fix..
Quanto tempo levaria?
svn
![Page 23: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/23.jpg)
Colocar changes no ‘stash’
Criar Branch
Git permite que o desenvolvedor seja mais ágil!
Quanto tempo levaria?
git
![Page 24: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/24.jpg)
(*) http://martinfowler.com/bliki/FeatureBranch.html
filosofiaFeature Branch (*)
Só código que funciona no master
“Commit all the fucking time”
“Eu não gosto de resolver conflito!”(aleal)
![Page 25: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/25.jpg)
Commit early,Commit often
Never Commit broken code
![Page 26: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/26.jpg)
http://www.flickr.com/photos/traftery/4773457853/
Mão na massa
![Page 27: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/27.jpg)
Configurando e Commit
# Configurando conta do usuário;$ git config -‐-‐global user.name "Alberto Leal"
$ git config -‐-‐global user.email [email protected]
$ 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 initInitialized empty Git repository in ~/meu_projeto/.git/
![Page 28: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/28.jpg)
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.txtnothing 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
![Page 29: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/29.jpg)
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 logcommit 4692340f4f326a4120337185474153e65c808cd1Author: Alberto Leal <[email protected]>Date: Sun Mar 25 19:13:59 2012 -‐0300
Initial Commit
![Page 30: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/30.jpg)
tag
Blob
Tree
O que é um commit?
Commitsha1: 4692340f4f326a4120337185474153e65c808cd1
v1.0
Curva de Aprendizado
Quebra de paradigma
![Page 31: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/31.jpg)
Commit(abcde)
/public
index.html
Commit(fghijl)
/public
index.html
whoami.html
Curva de AprendizadoO que é um commit?
![Page 32: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/32.jpg)
Working DirectoryStage areaRepository
Curva de Aprendizado
![Page 33: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/33.jpg)
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 diffdiff -‐-‐git a/README.txt b/README.txtindex 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
![Page 34: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/34.jpg)
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 masternothing to commit (working directory clean)
# Caso você tenha comitado as alterações feitas anteriormente, para reverter o commit, faça;$ git log commit 23a7e65d7353bd61935c627b13cad8890eea0de6Author: Alberto Leal <[email protected]>Date: Wed Apr 11 21:10:19 2012 -‐0300
Adding some lines
commit 909f2bbfc158b41619e90ea7679f3eb11dd46896Author: Alberto Leal <[email protected]>Date: Wed Apr 11 21:03:34 2012 -‐0300
Initial Commit
$ git revert 23a7e65d7353bd
![Page 35: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/35.jpg)
Diff e Revertendo Commit$ git log
commit 143059e977ea838b78c054d37f03a82f82051a7bAuthor: Alberto Leal <[email protected]>Date: Wed Apr 11 21:11:13 2012 -‐0300
Revert "Adding some lines" This reverts commit 23a7e65d7353bd61935c627b13cad8890eea0de6.
commit 23a7e65d7353bd61935c627b13cad8890eea0de6Author: Alberto Leal <[email protected]>Date: Wed Apr 11 21:10:19 2012 -‐0300
Adding some lines
commit 909f2bbfc158b41619e90ea7679f3eb11dd46896Author: Alberto Leal <[email protected]>Date: Wed Apr 11 21:03:34 2012 -‐0300
Initial Commit
![Page 36: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/36.jpg)
$ git branch * master
$ git branch * master
$ git branch new_feature$ git branch* master new_feature
$ git checkout -‐b another_featureSwitched to a new branch 'another_feature'
$ git branch* another_feature master new_feature
Criar BranchBranch
![Page 37: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/37.jpg)
$ 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.txtnothing 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$ lsREADME alberto.txt oi.txt ola.txt
BranchCriar Branch
![Page 38: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/38.jpg)
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.
lembra ...?
![Page 39: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/39.jpg)
$ git checkout another_feature$ lsREADME alberto.txt c.txt e.txt ola.txta.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_ajaxSaved working directory and index state On another_feature: login_with_ajaxHEAD is now at 08f9fbe Adding new files
$ git status# On branch another_featurenothing to commit (working directory clean)
StashColocar changes no ‘stash’
![Page 40: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/40.jpg)
$ git stash liststash@{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")
StashColocar changes no ‘stash’
![Page 41: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/41.jpg)
$ git checkout master
$ git status # On branch masternothing 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_featureSwitched 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 masterSwitched to branch 'master'
Resolução de conflitosResolvendo conflitos
![Page 42: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/42.jpg)
$ git merge another_featureAuto-‐merging a.txtCONFLICT (add/add): Merge conflict in a.txtAutomatic merge failed; fix conflicts and then commit the result.
$ git diffdiff -‐-‐cc a.txtindex 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 logcommit 36e2a5d1b4cdc74d967ced02a29190321adefbecMerge: e88ac64 d7a6544Author: Alberto Leal <[email protected]>Date: Wed Apr 11 22:00:50 2012 -‐0300 Merging branches
Resolução de conflitosResolvendo conflitos
![Page 43: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/43.jpg)
Procurando bug com git bisecthttp://imasters.com.br/artigo/15310/desenvolvimento/git-localizando-a-origem-de-um-bug-atraves-de-busca-
binaria-entre-os-commits
![Page 44: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/44.jpg)
QUEM USA?•Linux Kernel•Git•Perl•PHP•Eclipse•Gnome•KDE•Ruby on Rails•Android•PostgreSQL•Debian•X.org
•jQuery•node.js•Redis•CakePHP•mongodb•...
![Page 45: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/45.jpg)
FERRAMENTAS
•Github•Gitorious•SmartGit•Tortoise•...
![Page 46: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/46.jpg)
INSTALANDO GIT
Ubuntusudo apt-get install git-core git-doc git-svn git-gui gitk ssh
Windowshttp://msysgit.github.com/
![Page 47: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/47.jpg)
OBRIGADO!!
http://www.albertoleal.eti.br/category/git
![Page 48: Wokshop de Git](https://reader034.fdocument.pub/reader034/viewer/2022052321/5557ad36d8b42a4a5d8b4f0f/html5/thumbnails/48.jpg)
adesivos na minha mesa