Home > OS >  How can I safely git rebase commit history in master
How can I safely git rebase commit history in master

Time:03-03

My new team has not been using git in the most efficient way and my lead asked me to clean up the repo. They all have been working off of master - not creating branches. There are many small commits in master. I created a new branch bug_rebase_history and rebased squashing commits until there was one commit per day. This decreased the commits in master from 465 to 180.

How can I create a merge request in the GitLab web interface that will merge this rebase in a way that won't just add the new squashed commits on top of the HEAD? Is there a safer way to do this?

CodePudding user response:

How can I create a merge request in the GitLab web interface that will merge this rebase in a way that won't just add the new squashed commits on top of the HEAD?

It's not possible.

The only way to remove commits from a branch is to reset the branch and then force push it back out. If you re-write a protected branch you will need to force push that branch out from a client tool (and perhaps temporarily give yourself permission to force-push the protected branch).

A Merge (or Pull) Request can bring (merge) in new commits, but cannot remove any commits from a branch.

  • Related