1

I've been reading up on Orphaned git branches. My situation is described in the git manual under checkout which I found from this answer

This can be useful when you want to publish the tree from a commit without exposing its full history. You might want to do this to publish an open source branch of a project whose current tree is "clean", but whose full history contains proprietary or otherwise encumbered bits of code.

However, I'd like to work on that open source branch not just publish it. That is, I've pushed an orphan to GitHub, remote name origin. Our full history remains internal, remote name internal. On my local machine, I'd like to do development work pushing and pulling from origin, building on the orphaned branch, and occasionally our team would like to copy (push? merge?) our local & origin branches to internal.

I haven't found a question and answer that addresses this use case. Is this possible?

mankoff
  • 2,225
  • 6
  • 25
  • 42

1 Answers1

1

It is possible.

You can try creating your local orphan branch

 git checkout --orphan orphan_name

pushing it into github

 git push origin orphan_name

then create feature branch from the orphan_name

 git checkout -b open-source-feature

create some change and commit

 git commit -m "Open source feature"

push it into GitHub

 git push origin open-source-feature

and you can also create internal-feature from open-source-feature

 git checkout -b internal-feature origin/open-source-feature

and rebase it on top of internal/develop (for example)

 git rebase internal/develop

and push it to the internal repository

 git push internal internal-feature
Teneff
  • 30,564
  • 13
  • 72
  • 103
  • Thanks for this. One additional complication: How would we go about merging in changes from `internal` branches (but without their history)? – mankoff Jun 28 '23 at 14:20
  • You can create the branch off of the internal and rebase it on top of the origin branch. You can pass --interactive flag to squash commits or change the commit messages – Teneff Jun 28 '23 at 14:35