-
-
Save fabiocruzcoelho/f4a19077bcac63cfc219c5fa198d8e6a to your computer and use it in GitHub Desktop.
Exemplos de uso do Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Link com comandos (desfazendo as coisas) | |
https://git-scm.com/book/pt-br/v1/Git-Essencial-Desfazendo-Coisas | |
# Comandos basicos | |
git clone git@github.com:wedsonlima/git-presentation.git | |
git remote -v # pra onde o respositório está apontando | |
git branch # listar os branchs existentes | |
git branch tarefa1 | |
git checkout tarefa1 | |
echo 'arquivo 1' > file1.txt | |
git status | |
git add . | |
git commit -m "Commitando arquivo file1.txt" | |
# necessário fazer uma outra tarefa urgente | |
git checkout master | |
git checkout -b tarefa2 # fazer a cópia do master | |
git log --oneline --decorate # olhada rápida no log | |
git log --graph --pretty=format:'%C(yellow)%d%Creset %C(cyan)%h%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=short --all | |
echo 'arquivo 2' > file2.txt | |
git add . | |
git commit -m "Commitando aqruivo file2.txt" | |
gitg # ferramenta gráfica | |
git checkout master | |
git merge tarefa2 | |
git log | |
git remote -v | |
git push # git push origin master | |
git branch -d tarefa2 | |
git checkout tarefa1 | |
git log --oneline | |
echo 'nova frase no arquivo 1' >> file1.txt | |
echo 'arquivo 3' > file3.txt | |
git status | |
git add file1.txt file3.txt | |
git commit -m "Add file3.txt e modifcando file1.txt" | |
# merge | |
git checkout master | |
git merge tarefa1 | |
# gráfico de commits | |
git log --graph --oneline --decorate | |
# enviando modificacões para o repositorio | |
git push origin master | |
# atualizando o branch tarefa1 com o merge do master | |
git rebase master tarefa1 | |
# resolvendo conflitos | |
git checkout -b tarefa2 | |
echo 'tarefa2: escrevi primeiro' >> file1.txt | |
git status | |
git add . | |
git commit -a -m "tarefa2 escrevendo primeiro" | |
# simulando outro usuário criando um conflito | |
git checkout tarefa1 | |
echo 'tarefa1: escrevendo depois' >> file1.txt | |
git status | |
git diff | |
git commit -a -m "tarefa1 escrevendo depois" | |
git log --oneline --decorate | |
# shipar tarefa1 | |
git checkout master | |
git merge tarefa1 | |
git push origin master | |
git checkout tarefa1 | |
# merge da tarefa2 | |
git checkout master | |
git merge tarefa2 | |
git status | |
git diff | |
vim file1.txt | |
git add . | |
git commit -m "Resolvendo confilto" | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment