Conflitti di merge

Git intermedio

George Boorman

Curriculum Manager, DataCamp

Conflitti

  • Conflitto

    • Impossibile risolvere differenze nel contenuto di uno o più file tra branch
  • Modifica lo stesso file in due branch

  • Prova a fare il merge

  • Git non sa quale versione tenere

  • Conflitto!

Git intermedio

Versioni in conflitto di README.md

documentation branch

# Contents and usage

This repo contains source code 
for the DataCamp website.

It also contains source code for an 
AI-Assistant (recommendation system) 
that takes prompts from learners and 
returns suggested content
that they might be interested in. 

It is for internal use only, 
external access is prohibited.

main branch

# Contents and usage

This repo contains source code 
for the DataCamp website.

It is for internal use only, 
external access is prohibited.
Git intermedio

Merge

  • Dal branch main
git merge documentation
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
Git intermedio

Apri il file

nano README.md

file README che mostra le sezioni in conflitto in nano

Git intermedio

Sintassi dei conflitti in Git

file con conflitto annotato che mostra i contenuti nel branch main e nel branch documentation

Git intermedio

Risolvi il conflitto

editor web di nano che elimina la sintassi Git <<<<<<< documentation, ======= e >>>>>>> HEAD

  • Salva: Ctrl + O (non Ctrl + 0), poi Invio
  • Esci: Ctrl + X
Git intermedio

Fusione dei branch

  • Fai il merge dopo aver risolto il conflitto
git add README.md
git commit -m "Resolving README.md conflict"
git merge documentation
Already up to date.
  • Prevenire è meglio che curare!
Git intermedio

Let's practice!

Git intermedio

Preparing Video For Download...