3

I need some help. I have a 1 months old MR in gitlab with 5 commits of a feature that I have to revert.

I have hard time understanding how to solve git revert conflicts and frankly this three windows GUI on intellij idea is very confusing to me. I am like afraid that I will accept a bad change or miss something.

Is there any other way to make this merge conflict solving easier? I was thinking maybe I could just rebase to head where I added my commits, revert them without conflicts and then rebase that branch on latest develop?

In that case I would be solving merge conflict by adding stuff instead of removing old stuff and being afraid that I will mess up something. Goal is to create a revert feature MR.

Comments
  • 1
    git switch development
    git pull
    git switch -c revert-changes
    git revert <commitId> (or range with <commitIdBegin>..<commitIdEnd>
    git push
  • 0
    @IntrusionCM since when its possible to use multiple commits in git revert?
  • 1
    @stop i think a range was always possible, though you have to provide the range in the right order.

    I could be wrong, as it's muscle memory, though I'm pretty sure it's possible.
  • 1
    When you learn git, you will realize it's often hard to f-up (lose changes). Maybe go through https://learngitbranching.js.org

    I would create a new branch on the tip of your feature branch, drop unnecessary commits first, and then rebase it on the latest master.

    It's similar to the IntrusionCM's approach, but you will be able to solve conflicts more gradually.
  • 0
    @WildOrangutan i didnt catch it fully. Can you give an example?
  • 1
    1. Switch to a new branch on the tip of your old branch:
    "git switch -c <new-branch> <old-branch>"

    2. Rebase new branch to the branching point of your old branch and drop commits you don't need:
    "git rebase -i <old-branch-start>"

    3. Rebase to latest master:
    "git rebase <master>"
Add Comment