3

Somebody messed up the git repository with his merge. The only choice is to get back and throw away all changes before his commit. The problem is that the develop branch is protected from push and we have to use merge requests. I forked new branch from the last commit before his merge and pushed it to GitLab. Gitlab complains that the MR is six commits behind the target branch and it wants to merge only new commit in my branch. It did not reset.

I think that the only way is to remove the branch protection and fix it there directly. Am I right?

Leos Literak
  • 8,805
  • 19
  • 81
  • 156
  • You *could* also consider reverting the merge (sometimes tricky but doesn't need lifting branch protection and rewriting history). (There's also a possibility with `git commit-tree` discussed [here](https://stackoverflow.com/questions/59413307/git-revert-to-previous-commit-as-a-new-commit-using-tree-hashes) and [there](https://devblogs.microsoft.com/oldnewthing/20190513-00/?p=102490)) – Romain Valeri Oct 19 '20 at 13:46
  • Well, he moved a lot of files around, then renamed directories, did some fixes inside new directories .. Undo commit creates hundreds of conflicts. – Leos Literak Oct 19 '20 at 13:54
  • 2
    If you can lift protection, yes it will be way easier. Be sure to communicate with everyone involved of course, but you seem to know that already. – Romain Valeri Oct 19 '20 at 14:14
  • This commit-tree is a kind of magic. I rather stick with KISS approach. Thanks. – Leos Literak Oct 19 '20 at 14:25

0 Answers0