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

Jonathan.Brink picture Jonathan.Brink · Apr 8, 2015 · Viewed 19.6k times · Source

I'm trying to script rebasing and my script will take different paths depending on if the rebase results in any conflicts.

Is there a way to determine if a rebase would result in conflicts before executing the rebase?

Answer

jub0bs picture jub0bs · Oct 10, 2015

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