Git init

Preview:

DESCRIPTION

Palestra sobre Git apresentada no Evento TcheLinux Caxias do Sul de 2013. Devido a todo tipo de problema que pode ocorrer no desenvolvimento de um software, profissionais de TI, em especial programadores, devem conhecer e saber utilizar ferramentas de controle de versão. Git é um sistema de controle de versão distribuído, de código aberto, voltado à atender todo tipo de necessidade, desde pequenos a grandes projetos, de forma rápida e eficiente. O objetivo deste trabalho é apresentar o conceito de controle de versão, ensinando comandos básicos para a utilização da ferramenta git juntamente com repositórios online (github e bitbucket).

Citation preview

git initMatheus Pereira | matheper@gmail.com

Controle de versãoQuando foi salvo?Por que foi salvo?O que foi alterado?Quem alterou?

Manter históricoComparar alteraçõesReverter arquivos para estado anteriorTrabalho paralelo

Controle de versãoConcurrent Version System (CVS)Subversion (SVN)MercurialPerforceBazaarGit...

GitOpen SourceDistribuídoCriado por Linus TorvaldsMantido por Junio HamanoVersão estável: 1.8.3.4http://git-scm.com/

Quem usa?Instituto Communitas / Hadi.comLinux KernelGooglePostgreSQLFacebookLinkedInTwitter…

Distribuído x Centralizado

git-scm.com

Os três estados

Modificado (Modified)Preparado(Staged)Consolidado(Committed)

git-scm.com

Ciclo de vida

git-scm.com

Repositórios online

Inicializar repositório$ git init$ git remote add github https://github.com/matheper/gitInit.git

Clonar repositórioSSH$ git clone git@github.com:matheper/gitInit.git

HTTP$ git clone https://github.com/matheper/gitInit.git

Vincular repositório$ git remote add bitbucket git@bitbucket.org:matheper/gitinit.git

Status de arquivos$ vim hello.py$ git status$ git add hello.py$ git status$ vim hello.py$ git status# o que aconteceu?

Comparando arquivos$ vim readme.txt$ vim hello.py$ git diff$ git add readme.txt$ git diff$ git diff hello.py$ git diff --staged$ git add hello.py

Enviando alterações$ git commit -m “Primeiro commit”$ git push bitbucket master# o que aconteceu com o repositório do bitbucket? E com o github?$ git add hello.py$ git commit -m “Segundo commit”$ git push bitbucket master$ git push github master

Branch$ git branch

$ git branch novabranch$ git checkout novabranch# ou então...$ git checkout -b novabranch

$ git branch -a

Merge$ git checkout master$ git merge novabranch# e se acontecer um conflito?$ git status# git status sabe... foi no hello.py$ vim hello.py$ git add hello.py$ git commit -m “Conflito resolvido”

Comandos diversos$ git reset --hard commit_id$ git checkout hello.py novabranch$ git reset HEAD hello.py$ git checkout hello.py$ git branch -D novabranch$ git checkout bitbutcket :novabranch$ git remote prune bitbucket$ git tag -a v1.0 -m 'Tag versão 1.0'