1

I'm trying to set up an automatic merge/build system between two project branches, but I'm having trouble with deletions not coming over in my merges. Here's the setup.

I develop on the main branch - add, modify, and delete files. All changes committed to main.

I have a second release branch where the latest work from main is merged in, and a build is made and published.

When I perform the merge - git merge --no-commit -s recursive -Xtheirs main (run from release) - most things merge over well with a preference for items coming from main. However, files deleted on main do not get deleted on release.

I think this is just how git merge works - if there's no actual conflict, git just keeps the file on release, no deletion. But I need it to be gone. Are there any commands I can run to make this happen? Or can I do it manually somehow?


Update - fun detail: Environment seems to make a difference here. This works as expected on my laptop (things are deleted through the merge), but it's failing when it runs as a Github Action. Sorry if that makes this a totally different issue.

aormsby
  • 126
  • 5
  • It turns out this was a totally different problem having to do with submodules and merging between shallow clones. I was a fool - A FOOL! - to leave out that info in the question because it's a totally different problem than asked. Short story -- Fetch deeper than 1 if you're trying to merge. Then submodules won't be a pain and cause conflicts, and the merge will complete - which results in deleting the appropriate files! Sigh... coding is hard sometimes, y'all. – aormsby Oct 05 '21 at 03:25

1 Answers1

0

You must create a commit on main that includes the deleted files.

rm file1 file2
git add .
git commit -m "Delete file1 file2"
git checkout release
git merge --no-commit -s recursive -Xtheirs main

The deleted files should no longer exist on the release branch.

  • Oh, I do that. No issues making commits haha. Sorry, it seemed like a common-sense step, but I suppose this is a help forum. Gotta be clear. Will update. – aormsby Oct 04 '21 at 05:01