Rebase in a loop to deal with conflicts