0

Assuming I have only a master branch with commits

A (initial) --> B --> C --> D --> E (head, newest)

on my PC and in a private repository on GitHub.

Now I want to publish it, but commits A and B (the oldest) are containing hardcoded keys/passwords (I know that's bad practice, this was only a quick test).

Is it possible to clone the repo (on my PC) and push this version to a separate public origin only with commits C (now initial) --> D --> E?

So I still want the private unmodified/complete repo and another pruned one as a public version.

Which commands should I use if this is even possible?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Gumbini
  • 48
  • 6
  • 2
    Obviously, you have to combine the first *three* commits, not the first two, using the same method. And (I hope) obviously, you need to do this after making a clone of the repository first. And after you combined the first three commits, you need to do [this](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository). – mkrieger1 Sep 01 '21 at 22:08
  • Yes, that worked fine. Thank you! – Gumbini Sep 01 '21 at 22:54
  • The rebase does change all the commit hashes, so I think it is not possible to add two remotes for future commits to my original local repo. Am I right? – Gumbini Sep 01 '21 at 23:02
  • 1
    Rewritten history is indeed incompatible with original history (and in particular you *don't* want to put the original history back together with the rewritten history, since that introduces the two commits with the passwords!). Think of the rewrite as "new repository, keep separate from old repository". – torek Sep 02 '21 at 01:05

0 Answers0