Since you are dealing with a published branch that is supposedly being used by someone other than you, I would recommend that you return two commits with git revert
. From the branch in question:
git log
and find the SHA-1 hashes of the two commits in question. Then return them using:
git revert abcd1234..foobar12
where abcd1234
is the hash of the first (oldest) of the two commits, and foobar12
is the later of the two commits.
With git revert
, commits will be added that effectively destroy the two commits buried in your branch. An alternative to this approach would be to use the rebase or filter branch. But both of these methods include rewriting the history of your industry. This can cause a headache for anyone else using your branch, as they can no longer pull or push.
source share