5

Suppose I have Git repository like this:

git-repo/
    directory_1/
    directory_2/
    directory_3/

This has a long history, and the history contains some code that I don't want anyone to have access to. I also don't want to release directory_1.

I want to release directory_2 and directory_3, but with no history information. Going forward, I will be continuing development in the original repository, and would like to also update the release fork with these changes.

The original repository is hosted as a private repository on GitHub right now.

How should I do this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • I don't think git makes this easy. There's probably a better way, but you could make a fork, git rebase -i until you have the history you like, and cherry-pick future updates from your original repository. – A B Apr 04 '12 at 01:11
  • If you want separate permissions, you should be using separate repositories. – Borealid Apr 04 '12 at 01:16
  • @Borealid. I assume that I'll need to use separate repositories. How do I get there from where I am now? –  Apr 04 '12 at 01:18
  • @alberge, I like that suggestion. What would the cherry-picks look like? The commits to the original will be updating directories 1, 2, and 3, but I'd only want to cherry-pick the updates to directories 2 and 3 over to the release fork. –  Apr 04 '12 at 01:23
  • You'd have to individually cherry-pick any commit that touched those directories. With git it is much easier to have separate repositories for 1, 2, and 3 if you want to maintain separate history. – A B Apr 04 '12 at 01:36
  • Are you going to be developing in the new (public) repo? It sounds like you might just want a repo that's only updated via an occasional "[git export](http://stackoverflow.com/q/160608/85950)" from the private repo. – blahdiblah Apr 04 '12 at 02:36
  • @blahdiblah, I would not be developing in the new (public) repo. Yeah, git export might be good enough. –  Apr 04 '12 at 05:03
  • Is there a way to merge changes in the new repo back to the original one? – kerner1000 Mar 23 '17 at 19:20

2 Answers2

1

Given your clarification, it sounds like this setup could work for you:

  1. Make a new public repository with the Git exported parts of your private repository that you want to share.
  2. To update, replace the contents of the public repository with a fresh git export from the private repository.

The public repository won't inherently share any history with the private repository, but it sounds like that might not matter much for your purposes.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
blahdiblah
  • 33,069
  • 21
  • 98
  • 152
0

I would first go to the download page for your private repository. Something like:

github.com/jquery/jquery/downloads

Here you can simply get the files from the current repository with no history. After that you can create a new repository, and git commit in only the files/folders that you want on the new repository.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zombo
  • 1
  • 62
  • 391
  • 407