How to manage adding a private code snippet into each git release?

171 Views Asked by At

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).

enter image description here

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?

1

There are 1 best solutions below

0
eftshift0 On BEST ANSWER

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:

git checkout private
git merge -m "Release 1.0" --no-ff normal
git tag v1.0

Development continues in normal.... then you want to release 2.0:

git checkout private
git merge -m "Release 2.0" --no-ff normal
git tag 2.0

And so on.

If something has to change in private moving forward:

git checkout private
# add in your changes
git commit -m "Doing blahblahblah"

And now private is ready for more stuff.