Git Debug
+------------------------+
| Git Debug |
| |
| Diagnóstico |
| Troubleshooting |
| Resolução |
| |
| Debugging Avançado |
+------------------------+
Ferramentas de Debug
Variáveis de Ambiente
# Debug geral
GIT_TRACE=1
# Debug específico
GIT_TRACE_PACKET=1 # Protocolo
GIT_TRACE_PACK_ACCESS=1 # Acesso packfile
GIT_TRACE_PERFORMANCE=1 # Performance
GIT_TRACE_SETUP=1 # Setup
GIT_CURL_VERBOSE=1 # HTTP
Comandos Essenciais
Técnicas de Diagnóstico
Verificação de Integridade
# Verificar repositório
git fsck --full
# Verificar objetos
git verify-pack -v .git/objects/pack/*.idx
# Verificar refs
git for-each-ref --verify
Análise de Logs
+------------------------+
| NÍVEIS DE LOG |
| |
| • Trace |
| • Debug |
| • Info |
| • Warning |
| • Error |
+------------------------+
Problemas Comuns
Network Issues
Resolução
# Problemas de rede
GIT_CURL_VERBOSE=1 git clone <url>
# Problemas de autenticação
ssh -vT git@github.com
# Problemas de objeto
git prune && git gc
Debug Avançado
Análise de Performance
# Trace detalhado
GIT_TRACE_PERFORMANCE=1 git status
# Estatísticas de objetos
git count-objects -v
# Profiling
git maintenance run --task=gc --verbose
Ferramentas Externas
Boas Práticas
Prevenção
+------------------------+
| CHECKLIST |
| |
| • Backup regular |
| • Verificações |
| • Manutenção |
| • Monitoramento |
| • Documentação |
+------------------------+
Workflow de Debug
Identificar sintomas
Coletar informações
Reproduzir problema
Analisar logs
Aplicar solução
Verificar resolução
Automação
Scripts Úteis
#!/bin/bash
# Debug completo
debug_git() {
export GIT_TRACE=1
export GIT_TRACE_PERFORMANCE=1
export GIT_TRACE_PACKET=1
git "$@"
unset GIT_TRACE GIT_TRACE_PERFORMANCE GIT_TRACE_PACKET
}
Monitoramento
Recuperação
Dados Perdidos
# Recuperar commits deletados
git reflog
# Recuperar arquivos deletados
git fsck --lost-found
# Restaurar estado anterior
git reset --hard HEAD@{1}
Corrupção
# Verificar e reparar
git fsck --full
git prune
git gc --aggressive
# Clonar novamente se necessário
git clone --mirror <url>
Próximos Passos
Tópicos Relacionados
Git Performance
Git Maintenance
30 abril 2025