Sorry, there are mitigating circumstances, but no legal defence in this case.
A mandatory sentence of 12-18 months is likely. Suspended if VERY lucky and you play off the mitigating circumstances and remorse VERY well. DO NOT rely on the duty solicitor.
No court will accept that you intended him NO harm if you hit him. Even if not intentional it was reckless. Therefore you have completed the offence of GBH im sorry to say.
You are MORE than likely to get a custodial sentence. In this case, restraining him if safe would have been proportionate, hitting is not. Im sorry to have to give you the bad news. I would advise getting a solicitor and barrister or solicitor advocate ASAP.