23. Fusão

Metas

  • Aprender como fundir dois branches diferentes para restaurar as modificações para um único branch.

01 Fundindo em um único branch

Fundir junta as modificações de dois branches em um. Vamos voltar para o branch style e fundi-lo com o main.

Execute

git switch style
git merge main
git log --all --graph

Resultado

$ git switch style
Switched to branch 'style'
$ git merge main
Merge made by the 'ort' strategy.
 README | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README
$ git log --all --graph
*   a33deed 2023-11-28 | Merge branch 'main' into style (HEAD -> style) [Alexander Shvets]
|\  
| * ee16740 2023-11-28 | Added README (main) [Alexander Shvets]
* | 0ee0113 2023-11-28 | Renamed hello.html; moved style.css [Alexander Shvets]
* | 903eb1d 2023-11-28 | Included stylesheet into hello.html [Alexander Shvets]
* | 555372e 2023-11-28 | Added css stylesheet [Alexander Shvets]
|/  
* 9288a33 2023-11-28 | Added copyright statement with email [Alexander Shvets]
* b7614c1 2023-11-28 | Added HTML header (tag: v1) [Alexander Shvets]
* 46afaff 2023-11-28 | Added standard HTML page tags (tag: v1-beta) [Alexander Shvets]
* 78433de 2023-11-28 | Added h1 tag [Alexander Shvets]
* 5836970 2023-11-28 | Initial commit [Alexander Shvets]

Pelo merge periodico entre os branches main e style, você pode acompanhar quaisquer mudanças ou modificações ocorridas para manter a compatibilidade das mudanças de estilo na linha principal.

Porém, isso faz com que os gráficos de commits fiquem feios. Mais tarde vamos considerar a rebase como uma alternativa à fusão.

02 Próximo

Mas e se as modificações no branch main conflitarem com as modificações do style?