Ho due repository. Di volta in volta, voglio unire il contenuto di other
in main
. Tuttavia l'unione ignora i file cancellati. Mi spiego con un esempio:Git ignora il file cancellato sulla fusione
mkdir -p test/main test/other
cd test/other/
git init
touch one two three
git add .
git commit -m "Add one, two and three."
cd ../main/
git init
touch four
git add .
git commit -m "Add four."
Aggiungi other
-main
come remoto.
git remote add other ../other/
git fetch other
Unire il suo contenuto.
git merge --squash other/master
git commit -m "Merge other."
Aggiunge i file correttamente. Ora, rimuovere un file in other
.
cd ../other/
git rm two
git commit -m "Remove two."
Unisci modifiche in main
.
cd ../main/
git fetch other
git merge --squash other/master
Dopo l'unione git status
dice:
# On branch master
nothing to commit (working directory clean)
mi aspetterei l'unione per eliminare two
, come è stato eliminato in other
. Che cosa sto facendo di sbagliato?
È vero, questa spiegazione ha senso. Volevo fare una fusione di squash per non inquinare la storia di main con altri. Ma sembra che non ci sia altro modo. Grazie per l'aiuto! –
@GergoErdosi Se si desidera * visualizzare * la cronologia "non inquinata", esaminare l'opzione 'first-parent' su' git log'. – Borealid
Grazie per il suggerimento! –