Download - Git init
git initMatheus Pereira | [email protected]
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 [email protected]:matheper/gitInit.git
HTTP$ git clone https://github.com/matheper/gitInit.git
Vincular repositório$ git remote add bitbucket [email protected]: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'