I’m sure you could do this using SDF and some automated scripts, but if you think you need to, then you have a few problems. First, this is backwards of the way that Github is intended to be used, which is the source of truth for what should be deployed to production, rather than a reflection of what was done in production.
This also implies that there are people regularly modifying script code directly in your production account without review, oversight, or source control. That could very easily lead to major problems. Even if you capture the new code later, a poorly written script could do permanent damage before you detect it, and knowing that the code changed won’t help you at all with recovering from that kind of situation.