Tutorial de utilização do git, explicando passo a passo como fazer commits, pushes, merges, diffs, criar branchs, tags, adicionar um repositório remoto entre outras features do git.
6. 6
Vantagens
Histórico de alterações
Facilidade de reverter alterações
Facilidade de ramificar o projeto
Facilidade de marcar (tag) dados
Backup do código fonte
7. 7
Git
“É um sistema de controle de versão
distribuido gratuito e open source desenhado
para lidar com tudo, desde pequenos até
grandes projetos com rapidez e eficiência.”
[git-scm.com]
8. 8
Git
Foco em velocidade
Foco no design simples
Suporte robusto a desenvolvimento não linear
(milhares de branches paralelos)
Totalmente distribuído
Capaz de lidar eficientemente com grandes
projetos como o kernel do Linux
21. 21
status
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# App.java
nothing added to commit but untracked files present (use "git add"
to track)
62. 62
push
Este comando envia as alterações contidas no
repositório local para o repositório remoto
63. 63
push
$ git push origin master
Warning: Permanently added the RSA host key for IP address
'192.30.252.131' to the list of known hosts.
Counting objects: 24, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (24/24), 2.26 KiB, done.
Total 24 (delta 9), reused 0 (delta 0)
To git@github.com:hstreb/tutorial-git.git
* [new branch] master -> master
64. 64
push branches
$ git push origin tratarExcecao
Warning: Permanently added the RSA host key
for IP address '192.30.252.130' to the list of
known hosts.
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:hstreb/tutorial-git.git
* [new branch] tratarExcecao ->
tratarExcecao
65. 65
pull
É utilizado para baixar as alterações contidas
no repositório remoto
67. 67
stash
Stash é utilizado para adicionar várias
alterações em uma pilha, que é armazenada
localmente
68. 68
stash Adicionar alterações
$ git stash
Saved working directory and index state
"WIP on master: 049d078 added the index
file"
HEAD is now at 049d078 added the index file
(To restore them type "git stash apply")
69. 69
stash listar alterações já
realizadas
$ git stash list
stash@{0}: WIP on master: 049d078 added the
index file
stash@{1}: WIP on master: c264051... Revert
"added file_size"
stash@{2}: WIP on master: 21d80a5... added
number to log
70. 70
stash aplicar alterações
$ git stash apply
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will
be committed)
#
# modified: App.java
#
71. 71
stash aplicar e retirar da
lista as alterações
$ git stash pop
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will
be committed)
#
# modified: App.java
#
72. 72
stash aplicar alterações
mais antigas
$ git stash apply@{2}
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will
be committed)
#
# modified: App.java
#
73. 73
stash aplicar alterações
mais antigas
{0} representa o último stash que você fez;
{1} representa penúltimo, e assim por diante.
Essa sintaxe também aparece em outros
lugares (show, por exemplo).