How to partially export a git repository?

别来无恙 提交于 2019-12-06 08:59:26

问题


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?

回答1:


You could use git-filter-branch to extract the parts you want to import to Google Code.




回答2:


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.




回答3:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!