Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to partially export a git repository?

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?
like image 336
Piotr Findeisen Avatar asked Nov 01 '25 20:11

Piotr Findeisen


1 Answers

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.

like image 136
simpleuser Avatar answered Nov 03 '25 09:11

simpleuser