0

I think this was because of this branch was accidentally merge to dev but it was deleted manually. I'm not expert on git, is their anyway to merge my working branch that will merge all my changes and ignore the changes that deleted on dev?

ex.

Before it was accidentally push to dev (someone)
Branch A - 7 changes to Dev, Dev has now 7 changes then it deleted manually
Now branch A is done
Branch A - 20 Changes to Dev, but Dev has now 16 changes

can someone explain to me and how to fix my problem?

N. Alcuino
  • 130
  • 1
  • 7

1 Answers1

1

Firstly we need to clarify some things. When you say:

merge all my changes and ignore the changes that deleted on dev

This is different to how git works. If you touched any of these delete files, when you would merge/pull dev into your branch, or try to merge into dev, you would get a merge conflict. Which you don't mention in your question. So you can't simply keep your changes over theirs because your changes have nothing to do with theirs, if they did have conflicts, you could simply do this: this and choose ours with each file you wanted.

It more sounds like you want to undo their changes, which their are many different ways of doing.

  • Reset
  • Revert
  • Empty Merge
  • ... List goes on

Choosing how to undo changes really depends on how you view history, as well as if there are already other changes on top of the changes, and practically how competent you are with git.

I would probably merge dev into your branch and re-add the files by doing a diff with the history, just because that is probably easy to understand, and not too difficult. Before you merge, maybe do a tag first that way you easily find where you were before the merge (not necessary but I find it helpful).

As a rule of thumb, the more often you merge dev into your branch, the quicker and less pain you will have merging your changes back to dev. And you may find having a full fledged CI/CD pipeline and reviewing PRs will catch these problems in the future.

Derrops
  • 7,651
  • 5
  • 30
  • 60