Git: How to discard changes that you pulled ahead of you, and let your local changes become the new branch head

87 Views Asked by At

Someone I work with committed corrupted files to the master git branch. My local version of master branch is ahead with changes to keep, while his changes should go in the trash. I am trying to resolve this in Source Tree, I must pull his crap before I can push my stuff, and then when I try to discard them I get bunch of errors like "error: path '...' is unmerged" and "error: pathspec '...' did not match any file(s) known to git."

1

There are 1 best solutions below

0
Oladipo On

From you comment, it seems you push directly to remote master. I'd suggest you create a new branch, revert that person's corrupted code; then merge your current work onto that branch, you can then push that branch.

Check the accepted answer here if it helps: How to revert Git repository to a previous commit?