Too many commits in merge request

Hi everyone. My MR has been rejected because I wasn’t using a valid author. My MR also has more than one commit. I have changed the previous author to a new valid one. The thing is that I was reading on git squash, it permits to turn the n last commits into just one commit, nonetheless I have something like this in my commit history:

  • my commit 4
  • other talent’s commit
  • my commit 3
  • my commit 2
  • my commit 1

The reason for this is that, as I was working I pulled from origin/master and then merged into my branch. Can you give me some advice on what can I do so that I can turn all my commits into one without affecting the other talent’s commit and then push to my remote branch and make a new MR?

Edit: I have found this answer

So it looks like my workflow with my branch was messy. In this case is it better to delete my remote and local branches and start fresh?

Hi @existing-settler, you don’t need to delete your branch, you can try rebasing in interactive mode and just use drop for the commit you want to delete and squash for the commits you want to merge into one single commit.

Maybe this would help you.

1 Like

Hi @perceived-doubt, thank you for your answer. So, I can delete the commits in my log history (that are from other talents) by using d|drop in the git rebase command and s|squash the commits that I want to be considered as one commit. Please correct me if I’m wrong.

Edit 1: So I have managed to squash into one commit, but then I get this:

I understand that git pull is not what I need because that will pull those unwanted commits again.

Edit 2: I used this link to overcome the issue. Thanks a lot @perceived-doubt because you point me in the right direction.

@existing-settler glad I help, and just to avoid this kind is issues in the future, just consider to do the git pull on the master branch then checkout into the branch you are working on and do a git rebase master that rebase will put your commits on top of the new commits in the master branch.

1 Like