Thank you everyone. I've solved my problem. I managed to solve it with reference to different articles and questions.
I will explain the answer here along with things I've learned through my struggle.
To begin with, in order to selectively remove commits from history that are scattered around the best way Can be found in the answer to this question:
Specifically the answer by Charles Bailey. The closest to this answer was Stuart.
Note: Reverting a commit doesn't remove it from history, Reset does.
As for my particular situation I thought I have to follow the previous method for every commit that I don't want but actually the answer was simpler.
In my situation I had to reset git to the commit just before I pulled Repository B and it has to be done for all branches. Once this is done all the undesired commits from B disappeared from my history.
Another Interesting thing to mention is that using git Cherry-Pick or Revert on many commits isn't as straight forward as it sounds from online articles, least for me.
Thank you everyone.