I have two repositories. From time to time, I want to merge the content of other
into main
. However the merge ignores deleted files. Let me explain it through an example:
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."
Add other
to main
as remote.
git remote add other ../other/
git fetch other
Merge its content.
git merge --squash other/master
git commit -m "Merge other."
It adds the files correctly. Now, remove a file in other
.
cd ../other/
git rm two
git commit -m "Remove two."
Merge changes into main
.
cd ../main/
git fetch other
git merge --squash other/master
After the merge git status
says:
# On branch master
nothing to commit (working directory clean)
I would expect the merge to delete two
, as it was deleted in other
. What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…