git para iniciantes v1.2.0 @ php‘n rio 2012

148
Git para iniciantes

Upload: mauro-george

Post on 19-Jan-2015

1.608 views

Category:

Documents


7 download

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 dia

TRANSCRIPT

Page 1: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Git para iniciantes

Page 2: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Git para iniciantes1.2.0

Page 3: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Mauro... quem?

Page 4: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Mauro... quem?

Page 5: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Mauro... quem?

Page 6: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012
Page 7: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012
Page 8: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Mauro George

http://maurogeorge.github.comhttp://www.aprenderphp.com.br@maurogeorge

Page 9: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Sistemas de controle de versãoVCS (Version control systems)

Page 10: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Pra que?

Page 11: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Pra que?

Gerenciar diferentes versões de um arquivo

Page 12: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Pra que?

Guardar histórico de alterações de um arquivo

Page 13: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Pra que?

Saber quem fez e o porquê de cada alteração

Page 14: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Vantagens

Page 15: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Vantagens

Backup automático

Page 16: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Vantagens

Controle do histórico

Page 17: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Vantagens

Trabalho em equipe

Page 18: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Vantagens

Marcação e resgate de versões estáveis

Page 19: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Vantagens

Ramificação do projeto

Page 20: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Diferentes modelos

Page 21: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Centralizado

Page 22: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Centralizado

Necessita de um servidor central

Page 23: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Centralizado

Somente usuários autorizados podem fazer commits

Page 25: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Centralizado

Page 26: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Distribuído

Page 27: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

Distribuído

Commits podem ser feitos offline

Page 30: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Distribuído

Commits podem ser facilmente transferidos entre repositórios

Page 31: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Distribuído

Page 32: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Distribuído

Page 33: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Pesquisa

Page 34: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Utiliza:NenhumSubversionMercurialGitOutro

Pesquisa

Page 35: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Git

Page 36: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Git

Open source

Page 37: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Git

Desenvolvido originalmente por Linus Torvalds, com o objetivo de...

Page 38: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Git

.. manter o Kernel do Linux

Page 39: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Instalação

Page 41: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

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

GUIs

Page 45: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

GUIs Gitk para todas as plataformas

Page 46: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Gerenciador de pacotes

GUIs Gitg para Linux

Page 48: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

http://code.google.com/p/tortoisegit/

GUIs tortoisegit para Windows

Page 49: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Primeiros passos

Page 50: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

Primeiros passos

Criando um repositório

$ git init

Page 53: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Primeiros passos

Primeiro commit

$ git add .$ git commit -m "first commit"

Page 55: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Primeiros passos

Primeiro commit

$ git status

Page 57: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Fluxo básico

Page 59: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Fluxo básico

Estado dos arquivosUntrackedModifiedStagedCommited

Page 60: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Fluxo básico

Estado dos arquivos Untracked$ touch Readme$ git status

Page 62: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

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

Fluxo básico

Estado dos arquivos Modified$ git status

Page 66: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

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

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

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

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

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

Fluxo básico

Estado dos arquivos Commited$ git status

Page 74: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Dica

Colorindo o output$ git config --global color.ui true

Page 76: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

Comandos

Page 79: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Comandos

git diffVisualiza o que foi modificado

Page 80: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git diff$ git diff

Page 82: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git diff --word-diffVisualiza o que foi modificado, diferenciando por palavras

Page 84: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Comandos

git diff --word-diff$ git diff --word-diff

Page 85: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git diff --cachedVisualiza o que foi modificado e está staged

Page 87: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Comandos

git diff --cached$ git add hello_world.php$ git status

Page 88: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git diff --cached$ git diff

Page 90: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Comandos

git diff --cached$ git diff

Output:

Page 91: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Comandos

git diff --cached$ git diff --cached

Page 92: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

Comandos

git commit -am Envia de modified para commited diretamente

Page 95: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git commit -am $ git status

Page 97: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git commit -am $ git commit -am "added date on hello world"

Page 99: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git commit -am $ git status

Page 101: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Dica

Se o git não conhece ele não mexe

Page 103: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git logExibe o histórico com infomações dos commits

Page 105: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Comandos

git log$ git log

Page 106: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Comandos

git log --onelineExibe o log em apenas uma linha

Page 108: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Comandos

git log --oneline$ git log --oneline

Page 109: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Voltando no tempo

Page 111: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Voltando no tempo

git checkout <hash>$ git checkout bf3bd62

Page 113: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

$ 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

$ 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

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

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

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

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

Voltando no tempo

git revert <hash>Reverte um commit criando um novo

Page 120: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

$ git revert 518bad1

Voltando no tempo

git revert <hash>

Page 121: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

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

$ 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

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

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

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

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

Voltando no tempo

git checkout <hash> <arquivo>$ git status

Page 130: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Voltando no tempo

git checkout <hash> <arquivo>$ git diff --cached

Page 132: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

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

Voltando no tempo

git checkout .$ vim hello_world.php$ vim Readme

Page 135: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Voltando no tempo

git checkout .$ vim hello_world.php$ vim Readme

Page 136: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Voltando no tempo

git checkout .$ git status

Page 137: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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

Voltando no tempo

git checkout .$ git checkout .

Page 139: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Voltando no tempo

git checkout .$ git status

Page 140: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

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
Page 142: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

vimeo.com/2979844

23 de janeiro de 2005

Github

Page 143: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Github

19 de janeiro de 2009

vimeo.com/2979844

Page 144: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

https://github.com/BielSystems/boletophp/

Boleto PHP

Page 145: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

https://github.com/BielSystems/boletophp/

Boleto PHP

Page 146: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Boleto PHP

Page 147: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Perguntas?

Page 148: Git para iniciantes v1.2.0 @ PHP‘n Rio 2012

Obrigado!@maurogeorge

maurogeorge.github.com