To implement github like fork/pull request function in my project, the auto-merge feature need to detect conflict between source/target repository every time while viewing the pull request.
One solution comes to me is to analyze the 'git request-pull' output. Is there any easier method to detect the conflict?
To see the beginning of the merge conflict in your file, search the file for the conflict marker <<<<<<< . When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD .
I have deleted my previous answer, I didn't understand the question ...
Now here's the shiny new answer:
git merge --ff-only <branch>
If there are no conflicts, it will do a merge. With a conflict, it gives you a message: Not possible to fast-forward
. The console return code (echo $?) is 128 in this situation.
We've created a git-conflict-detector that check the latest pushed commit vs all existing branches.
It's a simple single script that is initiated by GitHub WebHook URL and even know to sent an HiChat notification when conflict is detected.
We based our solution on analyzing the git merge --ff-only <branch>
output as you can see here
We've open source it so all can enjoy, learn and contribute.
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