loop for removing common commits in case of branch merging