I started a local git repository. Now, at this point, I want to publish it, say to github, but I don’t want to publish the whole history of the project, just the latest revision.
In particular, I’d like to create a local “pub” branch, make some modification on it (possibly hiding sensitive information), and the publishing the “pub” branch.
If I were to do what I said using a plain push, I’ll find myself having all the “pub” history published to the remote repository, something I don’t want since sensitive information would be published too.
How can this be achieved?
Thanks!
Take a look at this question.
You could also just swap out the
.gitfolder in your source tree with a different one, and check your code into that when you want to publish.You can not, however, set up a branch in the same Git repository without sharing the history, because of the way Git works. A repository has a root commit of the initial state, and all other commits are simply deltas against that commit.
But while we are at it, if you don’t want to expose version control history, why not simply publish the code as a tarball with a version number, no reason to drag Git into it 🙂