27
GIT + GITHUB Sistema de Controle de Versão Distribuído + Code Sharing Mauricio Wolff

Git + git hub

Embed Size (px)

DESCRIPTION

Introdução ao GIT e Github, para o devdell

Citation preview

Page 1: Git + git hub

GIT + GITHUBSistema de Controle de Versão Distribuído + Code SharingMauricio Wolff

Page 2: Git + git hub

Controle de Versão• SCMS permitem vários desenvolvedores simultâneos,

preservam milestones do código e automatizam o backup.

• Podem ser:

Distribuído

BazaarMercurialGIT (05)

BitKeeper (98)

Centralizado

TFSSVNCVS

SCCS (72)

Page 3: Git + git hub

Terminologia• Repository

• Local onde ficam os arquivos e alterações feitas

• Revision• Ou version, o estado de toda a

tree do repositório num tempo específico

• Diff, Delta• Somente as alterações feitas

• Checkout• Criar uma cópia local do

repositório• Commit

• Envio de dados para o repositório

• Conflict• Diferentes usuários alterando as

mesmas linhas nos arquivos• Working Copy

• Cópia local (checked out)• Tag

• Snapshot do repositório, para facilidade de manutenção

• Trunk• Linha principal do projeto, que não

é um branch• Branch

• Linha alternativa de desenvolvimento, pode ser uma feature ou um branch experimental

Page 4: Git + git hub

Trunk, Tags, Branches

Tag v3

Feature 1 Branch

Test Branch

Tag v2

Tag v1

Trunk

Page 5: Git + git hub

Modelo Centralizado

• Dependência de Rede• File Lock• Backup no Server• Difícil de usar merge e

branches• Branches e Tags são na

verdade cópias do repositório

Page 6: Git + git hub

Modelo Distribuído

• Não precisa de Rede• Cada clone é o repositório

completo• Múltiplos Backups• Merges locais/remotos• Branches e Tags são somente

uma referência, não cópias• Não existe um trunk, a não ser

por convenção

1 1

1

22

3

3

Page 7: Git + git hub

História do GIT• Criado por Linus Torvalds em 2005• Alternativa ao BitKeeper, usado para manter o Linux

Kernel• Simplicidade e rapidez!

Page 8: Git + git hub

Instalando GIT no Windows• Download: http://code.google.com/p/msysgit/• Instalar, com a opção de usar o Command Prompt

Page 9: Git + git hub

Instalando GIT no Windows• Gerar a chave ssh para o github.com• Configurar o ~/.gitconfig

[color] ui = true

[color "diff"] whitespace = red reverse

[diff] renames = true

[alias] s = status d = diff ci = commit -v cia = commit -v -a co = checkout cp = cherry-pick p = push l = log ll = log -p lt = log trunk.. llt = log -p trunk.. lm = log master.. llm = log -p master.. b = branch who = shortlog -s –

[user] name = "Mauricio Wolff" email = [email protected]

[push] default = matching

Page 10: Git + git hub

Inscrição no GitHub• Projetos Open Source = free• Copiar a chave SSH e mais config

$ git config --global core.autocrlf input

Page 11: Git + git hub

Criando o primeiro Projeto

Page 12: Git + git hub

Criando o primeiro Projeto

Page 13: Git + git hub

Criando o primeiro Projeto

Page 14: Git + git hub
Page 15: Git + git hub
Page 16: Git + git hub

Alterando localmente, atualizando

Page 17: Git + git hub
Page 18: Git + git hub

Branching

Page 19: Git + git hub

Remote Branching

Page 20: Git + git hub

Merging

Page 21: Git + git hub

Remote Merging

Page 22: Git + git hub

Remote Merging

Page 23: Git + git hub
Page 24: Git + git hub

Branch Diff$ git diff bonsai

Page 25: Git + git hub

GIT Cheat Sheet• Criar

• git init• git add [. ou -A]• git clone [~/, git://, ssh://, http://]

• Mostrar• git status• git diff [$id1, $id2 ou $branch]• git log [-1]• git blame $file• git show $id• git show $id:$file• git branch (mostra todos)

• Adicionar ao Stage• git add [-A, -u, -i]

• Consertar• git reset --soft HEAD^ (ctrl + z)• git commit –a –-amend (refaz)

• Branches• git checkout $branch• git merge $branch• git branch $nome• git branch –d $nome

• Update• git fecth• git pull [remote]• git am -3 patch.file

• Publish• git commit –a• git format-patch origin• git push [remote, branch]• git tag v1.0

• Úteis• git fsck• git gc --prune

Page 26: Git + git hub

Referências• http://git-scm.com/• http://github.com/• http://help.github.com/• http://github.com/guides/git-cheat-sheet• Linus Torvalds on GIT: http://j.mp/3M94sb • Git - SVN Crash Course: http://git.or.cz/course/svn.html• A Git/TFS bridge: http://github.com/spraints/git-tfs

Page 27: Git + git hub

Q&AOlha o tempo antes...