git para iniciantes v1.1.0 @ iv fsldc
DESCRIPTION
Apresentada em 30/06/12 no IV FSLDC. 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.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/1.jpg)
Git para iniciantes
![Page 2: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/2.jpg)
Git para iniciantes1.1.0
![Page 3: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/3.jpg)
Mauro... quem?
![Page 4: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/4.jpg)
![Page 5: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/5.jpg)
![Page 6: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/6.jpg)
Mauro George
http://maurogeorge.github.comhttp://www.aprenderphp.com.br@maurogeorge
![Page 7: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/7.jpg)
Sistemas de controle de versãoVCS (Version control systems)
![Page 8: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/8.jpg)
Pra que?
![Page 9: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/9.jpg)
Pra que?
Gerenciar diferentes versões de um arquivo
![Page 10: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/10.jpg)
Pra que?
Guardar histórico de alterações de um arquivo
![Page 11: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/11.jpg)
Pra que?
Saber quem fez e o porquê de cada alteração
![Page 12: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/12.jpg)
Vantagens
![Page 13: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/13.jpg)
Vantagens
Backup automático
![Page 14: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/14.jpg)
Vantagens
Controle do histórico
![Page 15: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/15.jpg)
Vantagens
Trabalho em equipe
![Page 16: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/16.jpg)
Vantagens
Marcação e resgate de versões estáveis
![Page 17: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/17.jpg)
Vantagens
Ramificação do projeto
![Page 18: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/18.jpg)
Diferentes modelos
![Page 19: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/19.jpg)
Centralizado
![Page 20: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/20.jpg)
Centralizado
Necessita de um servidor central
![Page 21: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/21.jpg)
Centralizado
O checkout é uma cópia da estrutura dos arquivos do repositório
![Page 22: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/22.jpg)
Centralizado
Somente usuários autorizados podem fazer commits
![Page 23: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/23.jpg)
Centralizado
![Page 24: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/24.jpg)
Distribuído
![Page 25: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/25.jpg)
Distribuído
Cada cópia é um repositório com o histórico completo
![Page 26: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/26.jpg)
Distribuído
Não necessita de acesso a rede ou um servidor central
![Page 27: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/27.jpg)
Distribuído
Commits podem ser feitos offline
![Page 28: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/28.jpg)
Distribuído
Commits podem ser facilmente transferidos entre repositórios
![Page 29: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/29.jpg)
Distribuído
![Page 30: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/30.jpg)
Distribuído
![Page 31: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/31.jpg)
Pesquisa
![Page 32: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/32.jpg)
Utiliza:NenhumSubversionMercurialGitOutro
Pesquisa
![Page 33: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/33.jpg)
Git
![Page 34: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/34.jpg)
Git
Open source
![Page 35: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/35.jpg)
Git
Desenvolvido originalmente por Linus Torvalds, com o objetivo de...
![Page 36: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/36.jpg)
Git
.. manter o Kernel do Linux
![Page 37: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/37.jpg)
Git
“focado em velocidade, efetividade e usabilidade do mundo real em grandes projetos”
![Page 38: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/38.jpg)
Instalação
![Page 39: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/39.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 40: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/40.jpg)
Instalação Linux
apt-get$ sudo apt-get install git-core git-gui git-doc
![Page 41: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/41.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 42: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/42.jpg)
GUIs
![Page 43: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/43.jpg)
GUIs Gitk para todas as plataformas
![Page 44: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/44.jpg)
GUIs GitX (L) para Mac
http://gitx.laullon.com/ *GitX -> Enable Terminal Usage
![Page 45: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/45.jpg)
Gerenciador de pacotes
GUIs Gitg para Linux
![Page 46: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/46.jpg)
http://code.google.com/p/tortoisegit/
GUIs tortoisegit para Windows
![Page 47: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/47.jpg)
Primeiros passos
![Page 48: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/48.jpg)
Primeiros passos
Configuração$ git config --global user.name "Mauro George"$ git config --global user.email "[email protected]"
![Page 49: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/49.jpg)
Primeiros passos
Criando nosso projeto
$ mkdir project$ cd project$ touch hello_world.php
![Page 50: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/50.jpg)
Primeiros passos
Criando um repositório
$ git init
![Page 51: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/51.jpg)
Primeiros passos
Criando um repositório
$ git init
Output:Initialized empty Git repository in /path/to/my/project/.git/
![Page 52: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/52.jpg)
Primeiros passos
Primeiro commit
$ git add .$ git commit -m "first commit"
![Page 53: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/53.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 54: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/54.jpg)
Primeiros passos
Primeiro commit
$ git status
![Page 55: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/55.jpg)
Primeiros passos
Primeiro commit
$ git status
Output:# On branch masternothing to commit (working directory clean)
![Page 56: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/56.jpg)
Fluxo básico
![Page 57: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/57.jpg)
Fluxo básico
Estado dos arquivosUntrackedModifiedStagedCommited
![Page 58: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/58.jpg)
Fluxo básico
Estado dos arquivos UntrackedArquivos que o git não conhece
![Page 59: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/59.jpg)
Fluxo básico
Estado dos arquivos Untracked$ touch Readme$ git status
![Page 60: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/60.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 61: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/61.jpg)
Fluxo básico
Estado dos arquivos ModifiedArquivos que o git já conhece e que foram alterados
![Page 62: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/62.jpg)
Fluxo básico
Estado dos arquivos Modified$ vim hello_world.php
<?php echo 'Hello world';?>
![Page 63: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/63.jpg)
Fluxo básico
Estado dos arquivos Modified$ git status
![Page 64: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/64.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 65: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/65.jpg)
Fluxo básico
Estado dos arquivos StagedArquivos que serão enviados para o repositório
![Page 66: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/66.jpg)
Fluxo básico
Estado dos arquivos Staged$ git add hello_world.php$ git status
![Page 67: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/67.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 68: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/68.jpg)
Fluxo básico
Estado dos arquivos CommitedArquivos que já estão no repositório git
![Page 69: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/69.jpg)
Fluxo básico
Estado dos arquivos Commited$ git commit -m "showing hello world"
![Page 70: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/70.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 71: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/71.jpg)
Fluxo básico
Estado dos arquivos Commited$ git status
![Page 72: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/72.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 73: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/73.jpg)
Dica
Colorindo o output$ git config --global color.ui true
![Page 74: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/74.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 75: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/75.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 76: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/76.jpg)
Comandos
![Page 77: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/77.jpg)
Comandos
git diffVisualiza o que foi modificado
![Page 78: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/78.jpg)
Comandos
git diff$ vim hello_world.php
<?php echo 'Hello world, no IV FSLDC';?>
![Page 79: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/79.jpg)
Comandos
git diff$ git diff
![Page 80: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/80.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 IV FSLDC'; ?>\ No newline at end of file
![Page 81: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/81.jpg)
Comandos
git diff --word-diffVisualiza o que foi modificado, diferenciando por palavras
![Page 82: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/82.jpg)
Comandos
git diff --word-diff$ git diff --word-diff
![Page 83: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/83.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 IV FSLDC';+}?> No newline at end of file
![Page 84: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/84.jpg)
Comandos
git diff --cachedVisualiza o que foi modificado e está staged
![Page 85: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/85.jpg)
Comandos
git diff --cached$ git add hello_world.php$ git status
![Page 86: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/86.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 87: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/87.jpg)
Comandos
git diff --cached$ git diff
![Page 88: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/88.jpg)
Comandos
git diff --cached$ git diff
Output:
![Page 89: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/89.jpg)
Comandos
git diff --cached$ git diff --cached
![Page 90: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/90.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 IV FSLDC'; ?>\ No newline at end of file
![Page 91: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/91.jpg)
Comandos
Commitando nossas alterações para continuarmos...$ git commit -m "change hello world message"
![Page 92: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/92.jpg)
Comandos
git commit -am Envia de modified para commited diretamente
![Page 93: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/93.jpg)
Comandos
git commit -am $ vim hello_world.php
<?php echo 'Hello world, no IV FSLDC em 30/06/2012';?>
![Page 94: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/94.jpg)
Comandos
git commit -am $ git status
![Page 95: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/95.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 96: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/96.jpg)
Comandos
git commit -am $ git commit -am "added date on hello world"
![Page 97: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/97.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 98: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/98.jpg)
Comandos
git commit -am $ git status
![Page 99: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/99.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 100: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/100.jpg)
Dica
Se o git não conhece ele não mexe
![Page 101: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/101.jpg)
Comandos
Editando e commitando o Readme para continuarmos...$ vim Readme$ git add Readme$ git commit -m "added readme"
![Page 102: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/102.jpg)
Comandos
git logExibe o histórico com infomações dos commits
![Page 103: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/103.jpg)
Comandos
git log$ git log
![Page 104: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/104.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 105: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/105.jpg)
Comandos
git log --onelineExibe o log em apenas uma linha
![Page 106: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/106.jpg)
Comandos
git log --oneline$ git log --oneline
![Page 107: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/107.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 108: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/108.jpg)
Voltando no tempo
![Page 109: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/109.jpg)
Voltando no tempo
git checkout <hash>Volta para o commit informado em <hash>
![Page 110: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/110.jpg)
Voltando no tempo
git checkout <hash>$ git checkout bf3bd62
![Page 111: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/111.jpg)
$ git checkout bf3bd62
Voltando no tempo
git checkout <hash> Hash do primeiro commit
![Page 112: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/112.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 113: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/113.jpg)
Voltando no tempo
git checkout <hash>$ lshello_world.php$ cat hello_world.php
![Page 114: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/114.jpg)
Voltando no tempo
git checkout <hash> De volta para o futuro $ git checkout master
![Page 115: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/115.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 116: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/116.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 IV FSLDC em 30/06/2012';?>
![Page 117: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/117.jpg)
Voltando no tempo
git revert <hash>Reverte um commit criando um novo
![Page 118: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/118.jpg)
$ git revert 518bad1
Voltando no tempo
git revert <hash>
![Page 119: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/119.jpg)
Voltando no tempo
git revert <hash>$ git revert 518bad1
Hash do quarto commit.
Em que foi adicionada a data
![Page 120: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/120.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 121: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/121.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 122: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/122.jpg)
$ cat hello_world.php<?php echo 'Hello world, no IV FSLDC';?>
Voltando no tempo
git revert <hash>
![Page 123: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/123.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 124: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/124.jpg)
Voltando no tempo
git checkout <hash> <arquivo>Recupera o arquivo do commit informado
![Page 125: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/125.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git checkout 83d672c hello_world.php
![Page 126: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/126.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 127: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/127.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git status
![Page 128: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/128.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 129: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/129.jpg)
Voltando no tempo
git checkout <hash> <arquivo>$ git diff --cached
![Page 130: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/130.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 IV FSLDC';+ echo 'Hello world'; ?>\ No newline at end of file
![Page 131: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/131.jpg)
Voltando no tempo
git checkout .Recupera todos os arquivos sobreescrevendo as mudanças locais
![Page 132: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/132.jpg)
Voltando no tempo
git checkout .$ vim hello_world.php$ vim Readme
![Page 133: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/133.jpg)
Voltando no tempo
git checkout .$ vim hello_world.php$ vim Readme
![Page 134: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/134.jpg)
Voltando no tempo
git checkout .$ git status
![Page 135: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/135.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 136: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/136.jpg)
Voltando no tempo
git checkout .$ git checkout .
![Page 137: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/137.jpg)
Voltando no tempo
git checkout .$ git status
![Page 138: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/138.jpg)
Voltando no tempo
git checkout .$ git status
Output:# On branch masternothing to commit (working directory clean)
![Page 139: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/139.jpg)
Perguntas?
![Page 140: Git para iniciantes v1.1.0 @ IV FSLDC](https://reader034.vdocuments.site/reader034/viewer/2022050804/54bd186e4a795932448b463b/html5/thumbnails/140.jpg)
Obrigado!@maurogeorge
maurogeorge.github.com