'How to make git rebase fail, if merge conflicts appear

I'm currently writing trying to write a workflow, that rebases one branch onto another on each push. Now I want that action to fail, if any merge conflicts occur (as there is no way that my code would be able to resolve these).

Is there any flag or other way to make git rebase fail if merge conflicts appear? Can I reproduce this behaviour on another way?

How would I do this for git merge?

git


Solution 1:[1]

Even though it's not obvious from the documentation most git commands fail with exit code 1.

This answer shows this behaviour for git merge, while this one assumes the same bahaviour for git rebase.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jojomatik