1

How can I create a shallow clone of a single branch that can be pushed to a new remote and later be reintegrated into the original remote?

I need to send code to a customer. That customer wants to make changes that I need to integrate into my code base later. However, I cannot give the customer a full clone.

I can create a clone that is exactly what I want the customer to have.

git clone --branch customer-release --depth 1 url

I can remove my remote, make commits on a new branch (as the customer would do), add my remote again, and push the customer branch for integration onto my remote.

However, I cannot push the shallow clone onto a newly created remote (as the customer would want to do).
I experimented with orphan branches and rebasing but was ultimately unsuccessful.

  • Pretty sure this is a dup of https://stackoverflow.com/questions/19641108/split-git-repo-in-a-squashed-public-and-initial-private/19642508#19642508 – jthill Apr 07 '19 at 16:46

1 Answers1

0

To avoid any mistake, I would create a separate repo with just the code you want.
There would not be any history in it, but such a repo would be easy to push and collaborate on.

Once you want to re-integrate new commits from that separate repo to your own original repo, you can use format-patch/apply to export/re-import the relevant commits.

That seems safer than trying to isolate a branch from a full repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250