Git Pie: A Arte Ancestral do Versionamento 馃ェ Help

Mesclando Reposit贸rios Git

Estratégias de Mesclagem

Abordagens

MergingSubtreeSubmoduleManualAddMergeAddUpdateCopyCommit

Usando git subtree

Processo Básico

# Adicionar reposit贸rio como subtree git subtree add --prefix=subdir \ git@github.com:org/repo.git main --squash # Atualizar subtree git subtree pull --prefix=subdir \ git@github.com:org/repo.git main --squash

Preservando História

Técnicas

Merge

Merge

Preservar

Repo A

Repo Final

Repo B

Hist贸ria

Scripts de Mesclagem

Mesclagem com Histórico

#!/bin/bash # Script para mesclar reposit贸rios REPO_A="git@github.com:org/repo-a.git" REPO_B="git@github.com:org/repo-b.git" FINAL_REPO="merged-repo" # Preparar reposit贸rio final git init $FINAL_REPO cd $FINAL_REPO # Adicionar e mesclar repos git remote add -f repo-a $REPO_A git remote add -f repo-b $REPO_B git merge repo-a/main --allow-unrelated-histories git merge repo-b/main --allow-unrelated-histories

Reorganização de Arquivos

#!/bin/bash # Reorganizar estrutura ap贸s merge # Mover arquivos mkdir -p new/structure git mv old/path/* new/structure/ # Commit das mudan莽as git commit -m "refactor: reorganize repository structure" # Limpar e otimizar git gc --aggressive --prune=now

Resolução de Conflitos

Estratégias

ConflitosArquivosHist贸ricoBranchesRenomearMoverDeletarRebaseSquashCherry-pickRenameMergeDelete

Validação

Checklist

Verificar

Testar

Validar

Confirmar

Hist贸ria

Integridade

Funcionalidade

Estrutura

Referencias

Melhores Práticas

Recomendações

+------------------------+ | MESCLAGEM REPOSIT脫RIO| | | | 1. Backup repos | | 2. Planejar estrutura | | 3. Testar localmente | | 4. Resolver conflitos | | 5. Validar resultado | +------------------------+

Automação

CI/CD

#!/bin/bash # Script de CI para valida莽茫o # Verificar estrutura test -d "expected/path" || exit 1 # Testar funcionalidade ./run_tests.sh # Validar refer锚ncias git fsck --full # Verificar hooks test -x .git/hooks/pre-commit
22 abril 2025