My company uses git internally and we publish some of our work as an open source on Google Code which uses svn. (Should it support git, the problem would be probably the same.)
The problem is that we publish only part of our repository, so using git-svn as described on http://code.google.com/p/support/wiki/ImportingFromGit will not work.
- How to publish part of the repository? (For the first time I just copied files we want to publish.)
- How to synchronize the changes between published files and Code's repository?
You could use git-filter-branch to extract the parts you want to import to Google Code.
In git 1.7.11, we use a command like this to export just the raw files of one directory in the repository, without exporting the git control and history. Be sure to run it in an existing directory where you want the files to appear (i.e. make and cd to the destination directory first):
git archive --remote /local/master/project.git HEAD:open/src | tar x
- Replace /local/master/project.git with whatever you use to specify your repository (my example uses a local NFS master)
- replace HEAD with the branch name
- replace open/src with the directory within the repository to export
Using the --remote option, you don't even need to run this in a cloned copy, so it can be embedded within any other processes you wrap around your release mechanism.
You can further use the tar options to exclude some files from the selected directory tree.
One approach might be to create a separate Git repository for the public stuff, and include that as a submodule in the internal repository. Then it will be a lot easier to synchronise the public Git repository with the Google Code SVN repository.
来源:https://stackoverflow.com/questions/540565/how-to-partially-export-a-git-repository