I‘m new to Git. I would like to know how to add a private fixed code snippet into each release?
Let's say I want to add a few lines of code to a Git repository release v1. For the next release v2, I want to add the same lines of code again. And so on. (see attached scheme).
How do I manage this with Git / GitHub if the code additions include trusted information, such as access keys, that I don't want to publish on GitHub?

I would keep it on a separate (private) branch started from the branch where you do the normal development. Let's call the branches normal and private. Private has the private stuff, normal is where you do the normal development.
You create private from normal. Add in the private stuff and commit.
Coding continues going on in normal.
When you want to do a release:
Development continues in normal.... then you want to release 2.0:
And so on.
If something has to change in private moving forward:
And now private is ready for more stuff.