Eseguire un merging dei branches

Supponiamo che le modifiche del branch testing2 non ci servano, allora possiamo eliminare questo branch. Spostiamoci prima nel branch master git checkout master poi digitiamo git branch -D testing2".

Ora il branch testing2 è eliminato. Adesso vogliamo unire il branch test al branch master. Assicuriamoci di essere nel branch master ed inseriamo questo comando git merge testing.

A questo punto potreste ricevere un messaggio di errore che vi parla di conflitti. Questo succede quando sia nel branch testing che nel branch testing2 abbiamo eseguito delle modifiche sullo stesso file come nel caso nostro su prova. Ora se aprite il file in questione dovreste trovare una sezione come questa

<<<<<<<<<<<Head



testing

In sostanza il testo che vedete subito sopra ai trattini è stato inserito con il branch testing2. Cancellate questo testo ed eliminate la sezione HEAD e le frecce e poi salvate. Ora dovrebbero rimanere solo le modifiche che abbiamo eseguito sotto branch testing. Adesso git add . e poi git commit --m "merge".

Ora rieseguite git merge testing. Eseguiamo il comando push per inviare in remoto il commit git push -u origin master.