Leo Brito
Leo Brito

Reputation: 2051

Recovering removed files from merged branch

I had several changes on branch A which I was happy about. Accidentally, branch A was merged into unrelated branch B. While working on branch B, instead of reverting the offending merge (which I now realize would be the way to go), and both branches were unrelated, I removed or pulled from master the files I knew were changed (solely) by A.

B eventually was merged into master, and since A was wrongly merged into B, it is also seen as merged although every change it made was either removed or checked out.

So my question is: how can I recover the changes A was supposed to have?

I have the hashes, but I can't just branch and merge the desired commit in A because B, which is more recent, removed/checked out all changes in A.

Upvotes: 1

Views: 30

Answers (1)

Brian Phillips
Brian Phillips

Reputation: 13053

If the changes from A that were backed out on branch B with discreet commits (containing no other changes), you should use git revert <commit ID> to invert the inappropriate changes on the master branch.

Upvotes: 1

Related Questions