I'm having issues with merging branches of a shallow clone, and I can't seem to work my way through the steps required to make it happen. This one's a real git puzzler, and I look forward to finding someone who knows how to work this out.
I've written a Github Action that creates release builds for Hugo website projects. As provided by Github, I use actions/checkout to checkout the source branch of a repo, and I include the option to recurse submodules. (This is important because the merge conflict is happening as a result of the submodule references here.)
After checkout, my deploy scripts do a few things:
- Fetch and checkout the release branch where the build will be made
- Merge latest changes from the source branch to the release branch
- Build, commit, and push the release
If I set fetch-depth: 0
during the checkout step (clones the full history of the repo), it works great! The merge is handled by -s recursive Xtheirs
, and everything is fine.
However, if I leave the default fetch-depth
setting resulting in --depth=1
, I get a shallow clone in which the merge always results in a conflict because I don't have enough branch history for the merge to know how it should resolve itself. The merge fails, and nothing else can happen after that.
Based on that info --
- What git steps would I have to take to deepen the fetch history of the source branch, the target branch, and the submodule(s) enough to be able to merge the branches without conflict?
Test Cases --
I set up 2 test repos that you can find on this action wiki page. If you want to check out the action, the success/failure output, run your own tests, or just read more about what I've tried, please take a look. It would be too much to add here.
I struggled with this problem for a while before coming here, and now I'm hoping y'all can help me. Let me know if I missed any crucial info. Cheers!