git para iniciantes v1.2.0 @ php‘n rio 2012
DESCRIPTION
Apresentada em 10/11/12 no PHP‘n Rio 2012. Na palestra você verá uma introdução aos sistemas de controle de versão, passando pelos modelos centralizado e distribuído. Um pouco da história do git, a instalação e GUIs para Mac, Linux e Windows. As configurações e o fluxo básico para o dia a dia. Além de alguns comandos e dicas que ajudarão no dia a dia com o git, inclusive para quem já usa o git no seu dia a diaTRANSCRIPT
![Page 1: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/1.jpg)
Git para iniciantes
![Page 2: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/2.jpg)
Git para iniciantes1.2.0
![Page 3: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/3.jpg)
Mauro... quem?
![Page 4: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/4.jpg)
Mauro... quem?
![Page 5: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/5.jpg)
Mauro... quem?
![Page 6: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/6.jpg)
![Page 7: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/7.jpg)
![Page 8: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/8.jpg)
Mauro George
http://maurogeorge.github.comhttp://www.aprenderphp.com.br@maurogeorge
![Page 9: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/9.jpg)
Sistemas de controle de versãoVCS (Version control systems)
![Page 10: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/10.jpg)
Pra que?
![Page 11: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/11.jpg)
Pra que?
Gerenciar diferentes versões de um arquivo
![Page 12: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/12.jpg)
Pra que?
Guardar histórico de alterações de um arquivo
![Page 13: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/13.jpg)
Pra que?
Saber quem fez e o porquê de cada alteração
![Page 14: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/14.jpg)
Vantagens
![Page 15: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/15.jpg)
Vantagens
Backup automático
![Page 16: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/16.jpg)
Vantagens
Controle do histórico
![Page 17: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/17.jpg)
Vantagens
Trabalho em equipe
![Page 18: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/18.jpg)
Vantagens
Marcação e resgate de versões estáveis
![Page 19: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/19.jpg)
Vantagens
Ramificação do projeto
![Page 20: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/20.jpg)
Diferentes modelos
![Page 21: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/21.jpg)
Centralizado
![Page 22: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/22.jpg)
Centralizado
Necessita de um servidor central
![Page 23: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/23.jpg)
Centralizado
O checkout é uma cópia da estrutura dos arquivos do repositório
![Page 24: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/24.jpg)
Centralizado
Somente usuários autorizados podem fazer commits
![Page 25: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/25.jpg)
Centralizado
![Page 26: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/26.jpg)
Distribuído
![Page 27: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/27.jpg)
Distribuído
Cada cópia é um repositório com o histórico completo
![Page 28: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/28.jpg)
Distribuído
Não necessita de acesso a rede ou um servidor central
![Page 29: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/29.jpg)
Distribuído
Commits podem ser feitos offline
![Page 30: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/30.jpg)
Distribuído
Commits podem ser facilmente transferidos entre repositórios
![Page 31: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/31.jpg)
Distribuído
![Page 32: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/32.jpg)
Distribuído
![Page 33: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/33.jpg)
Pesquisa
![Page 34: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/34.jpg)
Utiliza:NenhumSubversionMercurialGitOutro
Pesquisa
![Page 35: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/35.jpg)
Git
![Page 36: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/36.jpg)
Git
Open source
![Page 37: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/37.jpg)
Git
Desenvolvido originalmente por Linus Torvalds, com o objetivo de...
![Page 38: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/38.jpg)
Git
.. manter o Kernel do Linux
![Page 39: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/39.jpg)
Git
“focado em velocidade, efetividade e usabilidade do mundo real em grandes projetos”
![Page 40: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/40.jpg)
Instalação
![Page 41: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/41.jpg)
Instalação Mac
DMGhttp://code.google.com/p/git-osx-installer/downloads/list?can=3
Homebrew (mxcl.github.com/homebrew)$ brew install git
![Page 42: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/42.jpg)
Instalação Linux
apt-get$ sudo apt-get install git-core git-gui git-doc
![Page 43: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/43.jpg)
Instalação Windows
msysgithttp://code.google.com/p/msysgit/downloads/list
* Use Git Bash Only** Checkout Windows-style, commit Unix-style line endings
![Page 44: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/44.jpg)
GUIs
![Page 45: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/45.jpg)
GUIs Gitk para todas as plataformas
![Page 46: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/46.jpg)
GUIs GitX (L) para Mac
http://gitx.laullon.com/ *GitX -> Enable Terminal Usage
![Page 47: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/47.jpg)
Gerenciador de pacotes
GUIs Gitg para Linux
![Page 48: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/48.jpg)
http://code.google.com/p/tortoisegit/
GUIs tortoisegit para Windows
![Page 49: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/49.jpg)
Primeiros passos
![Page 50: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/50.jpg)
Primeiros passos
Configuração$ git config --global user.name "Mauro George"$ git config --global user.email "[email protected]"
![Page 51: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/51.jpg)
Primeiros passos
Criando nosso projeto
$ mkdir project$ cd project$ touch hello_world.php
![Page 52: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/52.jpg)
Primeiros passos
Criando um repositório
$ git init
![Page 53: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/53.jpg)
Primeiros passos
Criando um repositório
$ git init
Output:Initialized empty Git repository in /path/to/my/project/.git/
![Page 54: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/54.jpg)
Primeiros passos
Primeiro commit
$ git add .$ git commit -m "first commit"
![Page 55: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/55.jpg)
Primeiros passos
Primeiro commit
$ git add .$ git commit -m "first commit"
Output:[master (root-commit) bf3bd62] first commit 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 hello_world.php
![Page 56: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/56.jpg)
Primeiros passos
Primeiro commit
$ git status
![Page 57: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/57.jpg)
Primeiros passos
Primeiro commit
$ git status
Output:# On branch masternothing to commit (working directory clean)
![Page 58: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/58.jpg)
Fluxo básico
![Page 59: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/59.jpg)
Fluxo básico
Estado dos arquivosUntrackedModifiedStagedCommited
![Page 60: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/60.jpg)
Fluxo básico
Estado dos arquivos UntrackedArquivos que o git não conhece
![Page 61: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/61.jpg)
Fluxo básico
Estado dos arquivos Untracked$ touch Readme$ git status
![Page 62: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/62.jpg)
Fluxo básico
Estado dos arquivos Untracked$ touch Readme$ git status
Output:# On branch master# Untracked files:# (use "git add <file>..." to include in what will be committed)## Readmenothing added to commit but untracked files present (use "git add" to track)
![Page 63: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/63.jpg)
Fluxo básico
Estado dos arquivos ModifiedArquivos que o git já conhece e que foram alterados
![Page 64: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/64.jpg)
Fluxo básico
Estado dos arquivos Modified$ vim hello_world.php
<?php echo 'Hello world';?>
![Page 65: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/65.jpg)
Fluxo básico
Estado dos arquivos Modified$ git status
![Page 66: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/66.jpg)
Fluxo básico
Estado dos arquivos Modified
Output:
# On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: hello_world.php## Untracked files:# (use "git add <file>..." to include in what will be committed)## Readmeno changes added to commit (use "git add" and/or "git commit -a")
![Page 67: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/67.jpg)
Fluxo básico
Estado dos arquivos StagedArquivos que serão enviados para o repositório
![Page 68: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/68.jpg)
Fluxo básico
Estado dos arquivos Staged$ git add hello_world.php$ git status
![Page 69: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/69.jpg)
Fluxo básico
Estado dos arquivos Staged$ git add hello_world.php$ git status
Output:# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: hello_world.php## Untracked files:# (use "git add <file>..." to include in what will be committed)## Readme
![Page 70: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/70.jpg)
Fluxo básico
Estado dos arquivos CommitedArquivos que já estão no repositório git
![Page 71: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/71.jpg)
Fluxo básico
Estado dos arquivos Commited$ git commit -m "showing hello world"
![Page 72: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/72.jpg)
Fluxo básico
Estado dos arquivos Commited$ git commit -m "showing hello world"
Output:[master 83d672c] showing hello world 1 files changed, 3 insertions(+), 0 deletions(-)
![Page 73: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/73.jpg)
Fluxo básico
Estado dos arquivos Commited$ git status
![Page 74: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/74.jpg)
Fluxo básico
Estado dos arquivos Commited$ git status
Output:# On branch master# Untracked files:# (use "git add <file>..." to include in what will be committed)## Readmenothing added to commit but untracked files present (use "git add" to track)
![Page 75: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/75.jpg)
Dica
Colorindo o output$ git config --global color.ui true
![Page 76: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/76.jpg)
Fluxo básico
Resumo
Editar os arquivos Vim / emacs / textmate / etc
Colocar os arquivos em staged git add nome do arquivo
Verificar as mudanças git status
Fazer o commit das mudançasgit commit -m “mensagem do commit”
![Page 77: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/77.jpg)
Dica
Sempre leia as mensagens do Git
Output:
# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: hello_world.php## Untracked files:# (use "git add <file>..." to include in what will be committed)## Readme
![Page 78: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/78.jpg)
Comandos
![Page 79: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/79.jpg)
Comandos
git diffVisualiza o que foi modificado
![Page 80: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/80.jpg)
Comandos
git diff$ vim hello_world.php
<?php echo “Hello world, no PHP'n Rio 2012”;?>
![Page 81: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/81.jpg)
Comandos
git diff$ git diff
![Page 82: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/82.jpg)
Comandos
git diff$ git diff
Output:diff --git a/hello_world.php b/hello_world.phpindex fe71dc6..04beafa 100644--- a/hello_world.php+++ b/hello_world.php@@ -1,3 +1,3 @@ <?php- echo 'Hello world';+ echo “Hello world, no PHP'n Rio 2012”; ?>\ No newline at end of file
![Page 83: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/83.jpg)
Comandos
git diff --word-diffVisualiza o que foi modificado, diferenciando por palavras
![Page 84: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/84.jpg)
Comandos
git diff --word-diff$ git diff --word-diff
![Page 85: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/85.jpg)
Comandos
git diff --word-diff$ git diff --word-diff
Output:diff --git a/hello_world.php b/hello_world.phpindex fe71dc6..04beafa 100644--- a/hello_world.php+++ b/hello_world.php@@ -1,3 +1,3 @@<?php echo “Hello [-world”;-]{+world, no PHP'n Rio 2012”;+}?> No newline at end of file
![Page 86: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/86.jpg)
Comandos
git diff --cachedVisualiza o que foi modificado e está staged
![Page 87: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/87.jpg)
Comandos
git diff --cached$ git add hello_world.php$ git status
![Page 88: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/88.jpg)
Comandos
git diff --cached$ git add hello_world.php$ git status
Output:# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: hello_world.php## Untracked files:# (use "git add <file>..." to include in what will be committed)## Readme
![Page 89: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/89.jpg)
Comandos
git diff --cached$ git diff
![Page 90: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/90.jpg)
Comandos
git diff --cached$ git diff
Output:
![Page 91: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/91.jpg)
Comandos
git diff --cached$ git diff --cached
![Page 92: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/92.jpg)
Comandos
git diff --cached$ git diff --cached
Output:diff --git a/hello_world.php b/hello_world.phpindex fe71dc6..04beafa 100644--- a/hello_world.php+++ b/hello_world.php@@ -1,3 +1,3 @@ <?php- echo 'Hello world';+ echo “Hello world, no PHP'n Rio 2012”; ?>\ No newline at end of file
![Page 93: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/93.jpg)
Comandos
Commitando nossas alterações para continuarmos...$ git commit -m "change hello world message"
![Page 94: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/94.jpg)
Comandos
git commit -am Envia de modified para commited diretamente
![Page 95: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/95.jpg)
Comandos
git commit -am $ vim hello_world.php
<?php echo “Hello world, no PHP'n Rio 2012 em 10/11/2012”;?>
![Page 96: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/96.jpg)
Comandos
git commit -am $ git status
![Page 97: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/97.jpg)
Comandos
git commit -am $ git status
Output:# On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: hello_world.php## Untracked files:# (use "git add <file>..." to include in what will be committed)## Readmeno changes added to commit (use "git add" and/or "git commit -a")
![Page 98: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/98.jpg)
Comandos
git commit -am $ git commit -am "added date on hello world"
![Page 99: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/99.jpg)
Comandos
git commit -am $ git commit -am "added date on hello world"
Output:[master 518bad1] added date on hello world 1 files changed, 1 insertions(+), 1 deletions(-)
![Page 100: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/100.jpg)
Comandos
git commit -am $ git status
![Page 101: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/101.jpg)
Comandos
git commit -am $ git status
Output:# On branch master# Untracked files:# (use "git add <file>..." to include in what will be committed)## Readmenothing added to commit but untracked files present (use "git add" to track)
![Page 102: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/102.jpg)
Dica
Se o git não conhece ele não mexe
![Page 103: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/103.jpg)
Comandos
Editando e commitando o Readme para continuarmos...$ vim Readme$ git add Readme$ git commit -m "added readme"
![Page 104: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/104.jpg)
Comandos
git logExibe o histórico com infomações dos commits
![Page 105: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/105.jpg)
Comandos
git log$ git log
![Page 106: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/106.jpg)
Comandos
git log$ git log
Output:commit a6aa0cb4d832a3a7c3a26001d89d8698e73790bbAuthor: Mauro George <[email protected]>Date: Fri Jan 20 15:59:33 2012 -0200
added readme
commit 518bad17f1bc064f4d542683925ae9f1003609bdAuthor: Mauro George <[email protected]>Date: Fri Jan 20 15:27:07 2012 -0200
added date on hello world
![Page 107: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/107.jpg)
Comandos
git log --onelineExibe o log em apenas uma linha
![Page 108: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/108.jpg)
Comandos
git log --oneline$ git log --oneline
![Page 109: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/109.jpg)
Comandos
git log --oneline$ git log --oneline
Output:53bc92d Revert "added date on hello world"a6aa0cb added readme518bad1 added date on hello world0e1b665 change hello world message83d672c showing hello worldbf3bd62 first commit
![Page 110: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/110.jpg)
Voltando no tempo
![Page 111: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/111.jpg)
Voltando no tempo
git checkout <hash>Volta para o commit informado em <hash>
![Page 112: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/112.jpg)
Voltando no tempo
git checkout <hash>$ git checkout bf3bd62
![Page 113: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/113.jpg)
$ git checkout bf3bd62
Voltando no tempo
git checkout <hash> Hash do primeiro commit
![Page 114: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/114.jpg)
$ git checkout bf3bd62
Voltando no tempo
git checkout <hash> Hash do primeiro commit
Output:Note: checking out 'bf3bd62'.
You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at bf3bd62... first commit
![Page 115: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/115.jpg)
Voltando no tempo
git checkout <hash>$ lshello_world.php$ cat hello_world.php
![Page 116: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/116.jpg)
Voltando no tempo
git checkout <hash> De volta para o futuro $ git checkout master
![Page 117: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/117.jpg)
Voltando no tempo
git checkout <hash> De volta para o futuro $ git checkout master
Output:Previous HEAD position was bf3bd62... first commitSwitched to branch 'master'
![Page 118: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/118.jpg)
Voltando no tempo
git checkout <hash> De volta para o futuro$ lsReadme hello_world.php$ cat hello_world.php<?php echo “Hello world, no PHP'n Rio 2012 em 10/11/2012”;?>
![Page 119: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/119.jpg)
Voltando no tempo
git revert <hash>Reverte um commit criando um novo
![Page 120: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/120.jpg)
$ git revert 518bad1
Voltando no tempo
git revert <hash>
![Page 121: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/121.jpg)
Voltando no tempo
git revert <hash>$ git revert 518bad1
Hash do quarto commit.
Em que foi adicionada a data
![Page 122: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/122.jpg)
Voltando no tempo
git revert <hash>$ git revert 518bad1
Hash do quarto commit.
Em que foi adicionada a data
Output:[master 53bc92d] Revert "added date on hello world" 1 files changed, 1 insertions(+), 1 deletions(-)
![Page 123: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/123.jpg)
Voltando no tempo
git revert <hash>$ git revert 518bad1
Hash do quarto commit.
Em que foi adicionada a data
Output:[master 53bc92d] Revert "added date on hello world" 1 files changed, 1 insertions(+), 1 deletions(-)
* Será solicitado para digitar uma mensagem do commit, mantenha a padrão por convenção
![Page 124: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/124.jpg)
$ cat hello_world.php<?php echo “Hello world, no PHP'n Rio 2012”;?>
Voltando no tempo
git revert <hash>
![Page 125: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/125.jpg)
Dica
Commits pequenos e constantes
Created model of User
Boa mensagem de commit
Created model of User, Post and Comments and added template files
Má mensagem de commit
![Page 126: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/126.jpg)
Voltando no tempo
git checkout <hash> <arquivo>Recupera o arquivo do commit informado
![Page 127: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/127.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git checkout 83d672c hello_world.php
![Page 128: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/128.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git checkout 83d672c hello_world.php
Hash do segundo commit.Em que foi criada a mensagem
![Page 129: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/129.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git status
![Page 130: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/130.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git status
Output:# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: hello_world.php#
![Page 131: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/131.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git diff --cached
![Page 132: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/132.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git diff --cached
Output:diff --git a/hello_world.php b/hello_world.phpindex 04beafa..fe71dc6 100644--- a/hello_world.php+++ b/hello_world.php@@ -1,3 +1,3 @@ <?php- echo “Hello world, no PHP'n Rio 2012”;+ echo 'Hello world'; ?>\ No newline at end of file
![Page 133: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/133.jpg)
Voltando no tempo
git checkout .Recupera todos os arquivos sobreescrevendo as mudanças locais
![Page 134: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/134.jpg)
Voltando no tempo
git checkout .$ vim hello_world.php$ vim Readme
![Page 135: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/135.jpg)
Voltando no tempo
git checkout .$ vim hello_world.php$ vim Readme
![Page 136: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/136.jpg)
Voltando no tempo
git checkout .$ git status
![Page 137: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/137.jpg)
Voltando no tempo
git checkout .$ git status
Output:# On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: Readme# modified: hello_world.php#no changes added to commit (use "git add" and/or "git commit -a")
![Page 138: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/138.jpg)
Voltando no tempo
git checkout .$ git checkout .
![Page 139: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/139.jpg)
Voltando no tempo
git checkout .$ git status
![Page 140: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/140.jpg)
Voltando no tempo
git checkout .$ git status
Output:# On branch masternothing to commit (working directory clean)
![Page 141: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/141.jpg)
![Page 142: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/142.jpg)
vimeo.com/2979844
23 de janeiro de 2005
Github
![Page 143: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/143.jpg)
Github
19 de janeiro de 2009
vimeo.com/2979844
![Page 144: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/144.jpg)
https://github.com/BielSystems/boletophp/
Boleto PHP
![Page 145: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/145.jpg)
https://github.com/BielSystems/boletophp/
Boleto PHP
![Page 146: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/146.jpg)
Boleto PHP
![Page 147: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/147.jpg)
Perguntas?
![Page 148: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012](https://reader033.vdocuments.pub/reader033/viewer/2022061221/54bd18694a7959ff308b466c/html5/thumbnails/148.jpg)
Obrigado!@maurogeorge
maurogeorge.github.com