I have a custom merge driver for git that helps merge lockfiles in a large monorepo shared by hundreds of engineers. Because lockfiles churn quite frequently, it's not uncommon for these files to result in merge conflicts while a PR is being reviewed (because master progresses). This means the PR branch should be updated manually after resolving conflicts on these lockfiles locally using this merge driver.
Question: Is there a way to configure this merge driver on GitHub (or Azure Repos) on the server-side such that this driver would be used for merging PR branches (as opposed to the default automerge)?
Select the Conflicts link to start resolve file conflicts. This will bring up a list of files with conflicts. Selecting a file lets you accept the changes in the source branch you're merging from with the Take Source button or accept the changes in the branch you're merging into using Keep Target.
Create a PR from the Pull requests pageOn the Repos > Pull requests page, select New pull request at upper right. Select the branch with the changes and the branch you want to merge the changes into, such as the main branch. Enter your PR details and create the PR.
Squash merging is a merge option that allows you to condense the Git history of topic branches when you complete a pull request. Instead of each commit on the topic branch being added to the history of the default branch, a squash merge adds all the file changes to a single new commit on the default branch.
Once the extension is installed, you can navigate to the Pull Request and you can view a new tab called Conflicts as shown below. Clicking on the Conflicts button you can see a new page where you can view the conflicts between the source and Target branches as shown below.
GitHub doesn't provide the ability to use custom merge drivers, and I'm not aware of any platform that does. Part of the reason for this is that custom merge drivers can execute arbitrary code and most hosting platforms are not interested in executing arbitrary code on behalf of users.
In addition, merges on GitHub are done with libgit2, which is designed to be fast and efficient when computing the merge and to abort early if the merge is not possible, and custom Git merge drivers wouldn't provide those features.
You could find some way to automerge pull requests that are approved to your satisfaction using a custom GitHub Actions operation that uses your custom merge driver and then pushes it to the repo. GitHub will show the branch as merged and close the pull request accordingly in that case. That's the closest you're likely going to be able to get, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With