Is there some kind of 'git rebase --dry-run', which would notify me of conflicts in advance?

At the time of writing (Git v2.6.1 v2.10.0), the git rebase command offers no --dry-run option. There is no way of knowing, before actually attempting a rebase, whether or not you're going to run into conflicts.

However, if you run git rebase and hit a conflict, the process will stop and exit with a nonzero status. What you could do is check the exit status of the rebase operation, and, if it is nonzero, run git rebase --abort to cancel the rebase:

git rebase ... || git rebase --abort

If you just want to see if the rebase would be successful but then you want to "roll back," you can alway reposition the branch tip back to the original commit. Just tag or make a note of the original SHA.

Or perhaps easier, create a new temporary branch in which to "stage" the rebase:

git checkout your-branch
git checkout -b tmp
git rebase other-branch

If it was successful but you want to "roll back," your-branch is untouched. Just git branch -D tmp and you're back to where you started from.

If there were conflicts and you did some work to resolve them and you now you want to keep the rebase, just reposition your-branch tip to tmp (and then git branch -D tmp).


I suspect that git rebase ... --dry-run is not possible, for the following reason.

When you're doing a git rebase, git will rollback to the starting point, then incrementally apply patches for each commit to bring the branch up to date. If it hits a conflict, it will stop & wait for you to resolve the conflict before continuing. The path that the rebase takes after that conflict depends upon how you resolve the conflict - if you resolve it a certain way, that might introduce (or eliminate) later conflicts.

Thus, git rebase ... --dry-run would only be able to give you the first conflict - reports of later conflicts will depend upon how that first conflict is resolved.

The only way I can think of doing this would be via git diff between the current position and the last commit in the branch you're rebasing to. But that won't really give you what you're looking for - you really just need a list of conflicting changes between the two points. There might be a way to do it with git diff, but it's not a normal patch.