Git Pie: A Arte Ancestral do Versionamento ๐Ÿฅง Help

Tabela Completa de Comandos

Comando Git

Descrição

Categoria

git init

Inicializa um novo repositório Git

๐Ÿ†• Básico

git clone <url>

Clona um repositório existente

๐Ÿ†• Básico

git clone <url> <pasta>

Clona para uma pasta específica

๐Ÿ†• Básico

git clone --depth 1 <url>

Clona apenas o último commit (shallow clone)

๐Ÿ†• Básico

git clone --bare <url>

Clona repositório sem working directory

๐Ÿ†• Básico

git add <arquivo>

Adiciona arquivo ao stage

๐Ÿ“ Arquivos

git add .

Adiciona todos os arquivos ao stage

๐Ÿ“ Arquivos

git add -p

Adiciona alterações interativamente

๐Ÿ“ Arquivos

git add -u

Adiciona arquivos modificados e removidos

๐Ÿ“ Arquivos

git rm <arquivo>

Remove arquivo do repositório

๐Ÿ“ Arquivos

git rm --cached <arquivo>

Remove arquivo do stage mantendo local

๐Ÿ“ Arquivos

git mv <origem> <destino>

Move ou renomeia arquivo

๐Ÿ“ Arquivos

git commit -m "<mensagem>"

Cria um novo commit

๐Ÿ“ Básico

git commit -am "<mensagem>"

Adiciona modificações e commita

๐Ÿ“ Básico

git commit --amend

Modifica o último commit

๐ŸŽ“ Avançado

git commit --no-verify

Commit ignorando hooks

๐ŸŽ“ Avançado

git status

Mostra o estado atual do repositório

๐Ÿ” Investigação

git status -s

Mostra status em formato curto

๐Ÿ” Investigação

git log

Mostra histórico de commits

๐Ÿ” Investigação

git log --oneline

Mostra histórico resumido

๐Ÿ” Investigação

git log --graph

Mostra histórico com grafo

๐Ÿ” Investigação

git log --author="nome"

Filtra commits por autor

๐Ÿ” Investigação

git log --since="1 week ago"

Mostra commits da última semana

๐Ÿ” Investigação

git log -p

Mostra diferenças em cada commit

๐Ÿ” Investigação

git log --stat

Mostra estatísticas de alterações

๐Ÿ” Investigação

git blame <arquivo>

Mostra quem alterou cada linha

๐Ÿ” Investigação

git blame -L 10,20 <arquivo>

Blame de linhas específicas

๐Ÿ” Investigação

git diff

Mostra alterações não staged

๐Ÿ” Investigação

git diff --staged

Mostra alterações staged

๐Ÿ” Investigação

git diff HEAD

Mostra todas as alterações

๐Ÿ” Investigação

git diff --word-diff

Mostra diferenças por palavra

๐Ÿ” Investigação

git diff branch1..branch2

Compara duas branches

๐Ÿ” Investigação

git branch

Lista branches

๐ŸŒณ Branches

git branch -r

Lista branches remotas

๐ŸŒณ Branches

git branch -a

Lista todas as branches

๐ŸŒณ Branches

git branch <nome>

Cria nova branch

๐ŸŒณ Branches

git branch -m <novo-nome>

Renomeia branch atual

๐ŸŒณ Branches

git branch --merged

Lista branches mergeadas

๐ŸŒณ Branches

git branch --no-merged

Lista branches não mergeadas

๐ŸŒณ Branches

git checkout <branch>

Muda para outra branch

๐ŸŒณ Branches

git checkout -

Volta para branch anterior

๐ŸŒณ Branches

git checkout -b <branch>

Cria e muda para nova branch

๐ŸŒณ Branches

git checkout -- <arquivo>

Descarta alterações em arquivo

๐ŸŒณ Branches

git checkout HEAD~1

Vai para commit anterior

๐ŸŒณ Branches

git switch <branch>

Muda para branch (Git moderno)

๐ŸŒณ Branches

git switch -c <branch>

Cria e muda branch (Git moderno)

๐ŸŒณ Branches

git branch -d <branch>

Deleta branch (se mergeada)

๐ŸŒณ Branches

git branch -D <branch>

Força deleção de branch

๐ŸŒณ Branches

git merge <branch>

Faz merge de uma branch

๐Ÿค Merge/Rebase

git merge --no-ff <branch>

Merge criando commit mesmo se fast-forward

๐Ÿค Merge/Rebase

git merge --squash <branch>

Merge combinando commits

๐Ÿค Merge/Rebase

git rebase <branch>

Faz rebase em uma branch

๐Ÿค Merge/Rebase

git rebase -i <commit>

Rebase interativo desde commit

๐Ÿค Merge/Rebase

git rebase --onto <base> <old> <new>

Rebase específico

๐Ÿค Merge/Rebase

git merge --abort

Cancela merge em andamento

๐Ÿค Merge/Rebase

git rebase --abort

Cancela rebase em andamento

๐Ÿค Merge/Rebase

git remote add <nome> <url>

Adiciona repositório remoto

๐Ÿ”„ Sincronização

git remote -v

Lista repositórios remotos

๐Ÿ”„ Sincronização

git remote show <nome>

Mostra informações do remoto

๐Ÿ”„ Sincronização

git remote rename <old> <new>

Renomeia remoto

๐Ÿ”„ Sincronização

git remote remove <nome>

Remove remoto

๐Ÿ”„ Sincronização

git push

Envia commits para remoto

๐Ÿ”„ Sincronização

git push -u origin <branch>

Push configurando upstream

๐Ÿ”„ Sincronização

git push --force

Força push (cuidado!)

๐Ÿ”„ Sincronização

git push --force-with-lease

Force push mais seguro

๐Ÿ”„ Sincronização

git pull

Atualiza do repositório remoto

๐Ÿ”„ Sincronização

git pull --rebase

Pull usando rebase

๐Ÿ”„ Sincronização

git fetch

Busca atualizações do remoto

๐Ÿ”„ Sincronização

git fetch --all

Busca de todos os remotos

๐Ÿ”„ Sincronização

git fetch --prune

Fetch removendo refs obsoletas

๐Ÿ”„ Sincronização

git tag <nome>

Cria tag leve

๐Ÿ“Œ Tags

git tag -a <nome> -m "<msg>"

Cria tag anotada

๐Ÿ“Œ Tags

git tag -l "v1.*"

Lista tags com padrão

๐Ÿ“Œ Tags

git tag -d <nome>

Remove tag local

๐Ÿ“Œ Tags

git push origin <tag>

Envia tag específica

๐Ÿ“Œ Tags

git push origin --tags

Envia todas as tags

๐Ÿ“Œ Tags

git push origin :refs/tags/<tag>

Remove tag remota

๐Ÿ“Œ Tags

git stash

Guarda alterações temporariamente

๐Ÿ“ฆ Stash

git stash save "mensagem"

Stash com descrição

๐Ÿ“ฆ Stash

git stash push -m "mensagem"

Stash moderno com mensagem

๐Ÿ“ฆ Stash

git stash --keep-index

Stash mantendo staging

๐Ÿ“ฆ Stash

git stash --include-untracked

Stash incluindo novos arquivos

๐Ÿ“ฆ Stash

git stash pop

Recupera e remove stash

๐Ÿ“ฆ Stash

git stash apply

Recupera mantendo stash

๐Ÿ“ฆ Stash

git stash list

Lista stashes salvos

๐Ÿ“ฆ Stash

git stash show

Mostra alterações do stash

๐Ÿ“ฆ Stash

git stash drop

Remove stash

๐Ÿ“ฆ Stash

git stash clear

Remove todos os stashes

๐Ÿ“ฆ Stash

git stash branch <nome>

Cria branch do stash

๐Ÿ“ฆ Stash

git reset HEAD~1

Desfaz último commit mantendo alterações

๐Ÿ’ฉ Correções

git reset --soft HEAD~1

Desfaz commit mantendo stage

๐Ÿ’ฉ Correções

git reset --hard HEAD~1

Desfaz commit e alterações

๐Ÿ’ฉ Correções

git reset --mixed HEAD~1

Reset padrão

๐Ÿ’ฉ Correções

git reset <arquivo>

Remove arquivo do stage

๐Ÿ’ฉ Correções

git revert HEAD

Cria commit que desfaz alterações

๐Ÿ’ฉ Correções

git revert -m 1 <commit>

Reverte merge commit

๐Ÿ’ฉ Correções

git clean -n

Lista arquivos a serem removidos

๐ŸŽ“ Avançado

git clean -df

Remove arquivos não rastreados

๐ŸŽ“ Avançado

git clean -xdf

Remove arquivos ignorados também

๐ŸŽ“ Avançado

git cherry-pick <commit>

Copia commit específico

๐ŸŽ“ Avançado

git cherry-pick -x <commit>

Cherry-pick com referência

๐ŸŽ“ Avançado

git rebase -i HEAD~n

Rebase interativo

๐ŸŽ“ Avançado

git submodule add <url>

Adiciona submódulo

๐ŸŽ“ Avançado

git submodule update --init

Inicializa submódulos

๐ŸŽ“ Avançado

git submodule update --recursive

Atualiza submódulos recursivamente

๐ŸŽ“ Avançado

git worktree add <path> <branch>

Cria worktree

๐ŸŽ“ Avançado

git worktree list

Lista worktrees

๐ŸŽ“ Avançado

git bisect start

Inicia busca binária

๐ŸŽ“ Avançado

git bisect good/bad

Marca commit como bom/ruim

๐ŸŽ“ Avançado

git bisect reset

Finaliza bisect

๐ŸŽ“ Avançado

git gc

Executa coleta de lixo

๐Ÿ“Š Performance

git gc --aggressive

Otimização mais agressiva

๐Ÿ“Š Performance

git prune

Remove objetos órfãos

๐Ÿ“Š Performance

git fsck

Verifica integridade do repositório

๐Ÿ“Š Performance

git count-objects -v

Conta objetos do repositório

๐Ÿ“Š Performance

git config --global

Define configurações globais

๐Ÿ› ๏ธ Configuração

git config --local

Define configurações do repo

๐Ÿ› ๏ธ Configuração

git config --list

Lista todas configurações

๐Ÿ› ๏ธ Configuração

git config --edit

Edita configurações no editor

๐Ÿ› ๏ธ Configuração

git remote prune origin

Remove branches remotas deletadas

๐Ÿงน Limpeza

git reflog

Mostra histórico de referências

๐Ÿ” Investigação

git reflog expire --expire=now --all

Limpa reflog

๐Ÿงน Limpeza

git maintenance start

Inicia manutenção automática

๐Ÿ“Š Performance

git verify-pack -v .git/objects/pack/pack-*.idx

Analisa objetos empacotados

๐Ÿ“Š Performance

git rev-parse HEAD

Mostra hash do commit atual

๐Ÿ” Investigação

git rev-list --count HEAD

Conta número de commits

๐Ÿ” Investigação

git shortlog

Resumo de commits por autor

๐Ÿ” Investigação

git describe

Descreve commit usando tags

๐Ÿ” Investigação

git archive

Cria arquivo do repositório

๐Ÿ“ฆ Arquivamento

git bundle create repo.bundle HEAD

Cria bundle do repositório

๐Ÿ“ฆ Arquivamento

git notes add -m "nota" <commit>

Adiciona nota a commit

๐Ÿ“ Notas

git grep "termo"

Busca termo no código

๐Ÿ” Investigação

git show <commit>

Mostra informações do commit

๐Ÿ” Investigação

git show-branch

Mostra branches e seus commits

๐Ÿ” Investigação

git whatchanged

Mostra histórico de mudanças

๐Ÿ” Investigação

git log --graph --oneline

Mostra log em formato de árvore

๐Ÿ” Investigação

git log --author="nome"

Filtra commits por autor

๐Ÿ” Investigação

git log --since="1 week ago"

Mostra commits da última semana

๐Ÿ” Investigação

git log --grep="feat"

Busca commits por mensagem

๐Ÿ” Investigação

git log -p <arquivo>

Mostra histórico de mudanças do arquivo

๐Ÿ” Investigação

git blame -L 10,20 <arquivo>

Mostra autores das linhas 10-20

๐Ÿ” Investigação

git diff --cached

Mostra diferenças staged

๐Ÿ” Investigação

git diff branch1...branch2

Compara branches desde ancestral comum

๐Ÿ” Investigação

git checkout -

Volta para branch anterior

๐ŸŒณ Branches

git branch --merged

Lista branches já mergeadas

๐ŸŒณ Branches

git branch --no-merged

Lista branches não mergeadas

๐ŸŒณ Branches

git push --delete origin <branch>

Remove branch remota

๐ŸŒณ Branches

git commit --amend --no-edit

Adiciona alterações ao último commit

๐Ÿ’ฉ Correções

git restore --staged <arquivo>

Remove arquivo do stage (Git moderno)

๐Ÿ’ฉ Correções

git restore <arquivo>

Descarta alterações não staged (Git moderno)

๐Ÿ’ฉ Correções

git rebase --onto main topic-1 topic-2

Rebases encadeados

๐ŸŽ“ Avançado

git merge-base branch1 branch2

Encontra commit ancestral comum

๐ŸŽ“ Avançado

git rev-parse --short HEAD

Mostra hash curto do commit atual

๐Ÿ” Investigação

git update-index --skip-worktree <arquivo>

Ignora mudanças locais

๐Ÿ› ๏ธ Configuração

git update-index --no-skip-worktree <arquivo>

Volta a rastrear mudanças

๐Ÿ› ๏ธ Configuração

29 abril 2025