>_FoxiRef
Git

Git Cheatsheet

Comandos Git frequentemente usados

#Configuração inicial

ComandoDescrição
git config --global user.name "[name]"Definir nome de usuário
git config --global user.email "[email]"Definir e-mail
git config --listListar todas as configurações
git initInicializar novo repositório
git clone [url]Clonar repositório remoto

#Comandos básicos

ComandoDescrição
git statusVerificar status
git add [file]Preparar arquivo
git add .Preparar todas as alterações
git commit -m "[message]"Criar commit
git commit -am "[message]"Preparar e fazer commit
git pushEnviar para o remoto
git pullObter do remoto
git fetchObter sem mesclar

#Branches

ComandoDescrição
git branchListar branches
git branch [name]Criar novo branch
git checkout [branch]Trocar de branch
git checkout -b [name]Criar e trocar
git switch [branch]Trocar de branch (novo)
git switch -c [name]Criar e trocar (novo)
git merge [branch]Mesclar branch
git branch -d [name]Excluir branch
git branch -D [name]Excluir forçadamente

#Histórico

ComandoDescrição
git logHistórico de commits
git log --onelineUma linha por commit
git log --graphMostrar gráfico
git log -pMostrar patches
git show [commit]Mostrar detalhes do commit
git diffMostrar alterações
git diff --stagedAlterações preparadas
git blame [file]Mostrar autor por linha

#Desfazer

ComandoDescrição
git restore [file]Descartar alterações
git restore --staged [file]Remover do staging
git reset HEAD~1Desfazer último commit (manter alterações)
git reset --hard HEAD~1Desfazer último commit (descartar)
git revert [commit]Reverter commit (novo commit)
git clean -fdRemover arquivos não rastreados

#Stash

ComandoDescrição
git stashGuardar alterações temporariamente
git stash save "[message]"Guardar com mensagem
git stash listListar stashes
git stash popAplicar e remover stash
git stash applyAplicar stash (manter)
git stash dropRemover stash
git stash clearLimpar todos os stashes

#Remoto

ComandoDescrição
git remote -vListar remotos
git remote add [name] [url]Adicionar remoto
git remote remove [name]Remover remoto
git push -u origin [branch]Definir upstream e enviar
git push origin --delete [branch]Excluir branch remoto

#Tags

ComandoDescrição
git tagListar tags
git tag [name]Criar tag
git tag -a [name] -m "[msg]"Criar tag anotada
git push origin [tag]Enviar tag
git push origin --tagsEnviar todas as tags

#Avançado

ComandoDescrição
git rebase [branch]Rebase
git rebase -i HEAD~[n]Rebase interativo
git cherry-pick [commit]Cherry-pick de commit
git bisect startIniciar bisect
git reflogLog de referências
git submodule add [url]Adicionar submódulo

#Perguntas frequentes (FAQ)

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

Git Cheatsheet - Referência de comandos | Foxi Dev Reference