-
-
Save alex-oliveira/5d4b9f84daf630a32f46 to your computer and use it in GitHub Desktop.
anotações sobre 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
#---------------------------------------------------------------------------------------------------- | |
# definindo nome e email padrão | |
#---------------------------------------------------------------------------------------------------- | |
git config --global user.name "{{meu-nome}}" | |
git config --global user.email "{{meu-email}}" | |
#---------------------------------------------------------------------------------------------------- | |
# definindo que o git deve colorir suas saidas | |
#---------------------------------------------------------------------------------------------------- | |
git config --global color.ui true | |
#---------------------------------------------------------------------------------------------------- | |
# inicializa o git em um diretório | |
#---------------------------------------------------------------------------------------------------- | |
git init | |
#---------------------------------------------------------------------------------------------------- | |
# adicionar arquivo na lista do próximo commit | |
#---------------------------------------------------------------------------------------------------- | |
git add {{arquivo}} | |
#---------------------------------------------------------------------------------------------------- | |
# adicionar TODOS os arquivos na lista do próximo commit ("." ou "-A") | |
#---------------------------------------------------------------------------------------------------- | |
git add . | |
#---------------------------------------------------------------------------------------------------- | |
# retira arquivo da lista do próximo commit | |
#---------------------------------------------------------------------------------------------------- | |
git reset HEAD {{arquivo}} | |
#---------------------------------------------------------------------------------------------------- | |
# realiza um commit e registra uma mensagem (-m) | |
#---------------------------------------------------------------------------------------------------- | |
git commit -m "{{descrição}}" | |
#---------------------------------------------------------------------------------------------------- | |
# adiciona TODOS os arquivos (-a) e realiza commit com mensagem (-m) | |
#---------------------------------------------------------------------------------------------------- | |
git commit -a -m "{{descrição}}" | |
#---------------------------------------------------------------------------------------------------- | |
# apresenta log de commits do repositório | |
#---------------------------------------------------------------------------------------------------- | |
git log | |
#---------------------------------------------------------------------------------------------------- | |
# listando a branchs do repositorio local | |
#---------------------------------------------------------------------------------------------------- | |
git branch | |
#---------------------------------------------------------------------------------------------------- | |
# listando a branchs do repositorio local e do remoto | |
#---------------------------------------------------------------------------------------------------- | |
git branch -a | |
#---------------------------------------------------------------------------------------------------- | |
# ativando outra branch | |
#---------------------------------------------------------------------------------------------------- | |
git checkout {{nome-branch}} | |
#---------------------------------------------------------------------------------------------------- | |
# criando uma branch a partir da atual | |
#---------------------------------------------------------------------------------------------------- | |
git checkout -b {{nome-nova-branch}} | |
#---------------------------------------------------------------------------------------------------- | |
# criando uma branch a partir de uma outra branch remota | |
#---------------------------------------------------------------------------------------------------- | |
git checkout -b {{nome-nova-branch}} origin/{{nome-branch-remota}} | |
#---------------------------------------------------------------------------------------------------- | |
# removendo branch | |
#---------------------------------------------------------------------------------------------------- | |
git branch -d {{nome-branch}} | |
#---------------------------------------------------------------------------------------------------- | |
# ativar um determinado commit anterior | |
#---------------------------------------------------------------------------------------------------- | |
git checkout {{hash}} | |
#---------------------------------------------------------------------------------------------------- | |
# removendo commits anterior ("soft" move alterações para "untracked"; "hard" as elimina) | |
#---------------------------------------------------------------------------------------------------- | |
git reset HEAD~1 --soft | |
#---------------------------------------------------------------------------------------------------- | |
# fazendo merge da branch atual com outra branch | |
#---------------------------------------------------------------------------------------------------- | |
git merge {{nom-outra-branch}} | |
#---------------------------------------------------------------------------------------------------- | |
# adicionar o repositório de origem (origin) às configirações do git ("origin" é um padrão utilizado) | |
#---------------------------------------------------------------------------------------------------- | |
git remote add origin {{url-do-repositorio}} | |
#---------------------------------------------------------------------------------------------------- | |
# clonando um repositorio | |
#---------------------------------------------------------------------------------------------------- | |
git clone {{url-do-repositorio}} {{nome-novo-repositorio}} | |
#---------------------------------------------------------------------------------------------------- | |
# enviando alterações locais para a branch master do repositório de origem (origin) | |
#---------------------------------------------------------------------------------------------------- | |
git push origin master | |
#---------------------------------------------------------------------------------------------------- | |
# puxa as atualizações da brach remota (origin) para a branch local (master) | |
#---------------------------------------------------------------------------------------------------- | |
git pull origim master | |
#---------------------------------------------------------------------------------------------------- | |
# criando uma nova tag | |
#---------------------------------------------------------------------------------------------------- | |
git tag {{nome-versao}} | |
#---------------------------------------------------------------------------------------------------- | |
# apresentando uma lista (-l) das tag existentes | |
#---------------------------------------------------------------------------------------------------- | |
git tag -l | |
#---------------------------------------------------------------------------------------------------- | |
# enviando as tags locais para o repositório remoto (origin) | |
#---------------------------------------------------------------------------------------------------- | |
git push origin master --tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment