crazy2be
crazy2be

Reputation: 2252

Git: Transfer Specific Files and Histories From One Repository to Another

First of all, i've read all of the following: - Is it possible to move a bunch of files from one git repository to another while preserving (most) history? - Remove sensitive files and their commits from Git history - Can I pull only certain files from another git repository? I've been unable to get any of these solutions to work, possibly at least partially due to my unfamiliarity with advanced git commands, such as git rebase.

Background

For the past year, i've been volunteering with a few other programmers on a website for a NPO, written in go. In the process, i've developed a distributed, modular, multi-threaded, fault-tolerant web framework that is implemented using concurrent processes, combined with a reverse http proxy that dispatches to the various modules. The web framework is written by me, although there are modules written by the other programmers. All of our changes have been pushed to one central git repository, including the modules, framework, libraries (jQuery, tinymce, etc).

Given the extensive work involved in creating this framework, and the lack of such a solution for go programmers at the moment, I was considering releasing the project as open source. However, I only want to release the actual framework, not the modules, libraries, or other things that are sitting in the repo. In particular, there is at least one module that uses a hard-coded authentication key in order to access a web API, something that you would certainly not wish to have in a public release (although it's not enough of a security concern to be an issue for the other programmers working on the site). Additionally, the reverse http proxy checks a cookie's value in order to allow the entire site to be password-protected, with the cookie's value being hard-coded.

If possible, having the commit history from git would be an asset, as it would show people who are investigating the framework that it has a history, as well as showing them the evolution of it's design, and the design decisions involved.

Question

Using git, how can I include only specific files, and the history of those specific files, when releasing a formally internal product as open source?

Bonus: Is there some way to not include the history for specific lines in a specific file (as well as removing the lines)?

Upvotes: 3

Views: 982

Answers (2)

Dustin
Dustin

Reputation: 91050

The easiest way to do it is to clone the entire repo and learn some intricacies of filter-branch.

It's actually not that hard. Depending on how it's laid out, you can write a small script that will remove the presence of certain files as it constructs a new history. A subdirectory filter can pul up parts if needed.

For removing some lines, use annotate to find the version that introduced the lines that you want removed, and rebase -i that_revision^ then drop it. It'll cause some rebase failures, but they'll be easy to take care of.

These kinds of exercises are pretty easy and safe and get you down a path you don't typically explore with git. I imagine it'd be a lot of fun. :)

Upvotes: 3

ralphtheninja
ralphtheninja

Reputation: 133168

It seems you are looking for git bundle:

http://www.kernel.org/pub/software/scm/git/docs/git-bundle.html

Upvotes: -1

Related Questions