It turns out that I have been working on branch A while another person from another team made 2 commits to the same branch and pushed, now from my team it won't let me push my changes without first pulling and bringing those 2 commits, like Can I undo or delete them or pass my local content to another branch to finally push and integrate?
Assuming that the common ancestor between your local version of branch A and theirs is the commit with sha
#asdfgh
If your colleague wants to preserve his test commits, he can move them to another branch (ditto you to move yours to a copy of branchA if you want to go that route):
You can then push by forcing the HEAD of the remote to be the common ancestor
After that, you can bring back that remote that was clean again and push without problems:
It could be shorter than you did yourself from now on
And with that step on what is in the remote with what you have in your local, thus leaving the erroneous commits of history. But this path leaves open an edge where your colleague won't be able to work on that branch as long as he still has dirty commits.
if what you need to do is push your changes back to the same branch A by removing those two commits from the remote repository, first part your local HEAD on branch A with your current commits to a backup:
now branchA must update in the HEAD of origin, for that you must return to the common commit from where the commits of the other person and yours start, if you do a git log, it should be marked where you currently have your origin since you have not done pull, let's say it's "abc123"
now you should clean the remote repo
integrate your changes
and finally update the repo again with your changes