I guess another question would also be how do you handle scrubbing of identifying data such as IPs , emails, or hostnames? Can your privately highlight any fields that should be changed?
You have to handle this outside of any public repo. Because the entire point of a repo is making all of the commit history available.
What I do is make a copy of whatever script I want to publish and then redact things.
I've let things slip before and had to nuke an entire project to remove any history.
GitLab has a nice feature to block secrets. I haven't personally used it yet but they've been touting it in the new release.