Someone pushed the following line to our repository:
git = ['a', 'w', 'e', 's', 'o', 'm', 'e', BugSyntaxErrorBug]
git = ['a', 'w', 'e', 's', 'o', 'm', 'e']
This is how I would do it.
tag these so you can restore if something goes wrong.
git tag MyOldCommit BADCOMMIT git tag MyOldMaster master
if you need to you can recover master unchanged with
git branch -f master MyOldMaster
now checkout the bad commit to a new branch
git checkout -b MyFixedCommit BADCOMMIT
after removing the offending bytes, replace the old commmit with new one.
git commit --amend -m"my commit message"
go back to your old branch master branch
git checkout master
rebase master (and only master!!!) onto MyFixedCommit
git rebase --onto MyFixedCommit BADCOMMIT master
git will re-play (commit by commit) the changes from BADCOMMIT to tip of master on to MyfixedCommit. You will have to resolve any conflicts that Git finds on the way.
!!Since you are re-writing history, the commit chain of master will now be different other user's tags and branches that referenced the old master commit chain!!