1

Background At our network share we have some bare git repositories that are used for file exchange (and version control, etc.) during development. Unfortunately, it happens quite often that people that are not involved in the development request access to just a small subset of files of this repository. These colleagues often have no git available.

What I need Therefore, I want to provide, parallel to the bare repository, an always-up-to-date copy of the working files of my bare repository. These working files are not intended for being changed.

Approaches? Do you have any idea how to cleverly approach this problem?

I know I could copy the whole files each time I am updating the repository, but this is costly in time and traffic. This seems to be such a basic thing...

matheburg
  • 2,097
  • 1
  • 19
  • 46

2 Answers2

2

At any point you can export an archive of a subfolder of a git repo (using git archive):

git archive -o ../subarchive.zip HEAD:subdir

That way, you only have to copy one (archive) file.

You can combine that with a post-receive hook, as I saw 3 years ago:
That allows, on each push, to archive, copy and uncompress the archive, in order to propose a folder structure which mirrors the latest state of your repo.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, this is a really helpful first idea! However, in an ideal case I would like to have just all files to be available parallel to the bare-repo (read-only ofc); these files should be incrementally updated when I am pushing something to the bare-repo. – matheburg Jan 13 '16 at 09:44
  • @matheburg add a pre-receive hook which will build and export the archive on each push – VonC Jan 13 '16 at 09:46
  • @matheburg I have edited the answer to include a reference to an example of such a post-receive hook; – VonC Jan 13 '16 at 10:28
1

Finally, we are using the following solution: We have a non-bare mirror repository on the server from which we pull automatically when our bare-repository is updated, via a joint update script (Windows, batch):

@echo off
:: define server pathes
set serverpath_bare=\\my_server_path\bare
set serverpath_mirror=\\my_server_path\mirror

:: make sure:
::  + your latest changes are committed to your local repository
::  + the repositories (bare and mirror) exist (e.g. via clone)
::  + ...

:: specify git server repository
git remote add server \%serverpath_bare%

:: update git server repository (1st: pull, 2nd: push)
git pull --stat server master
git push server master

:: mirroring: bare -> mirror
pushd %serverpath_mirror%
git remote add server \%serverpath_bare%
git pull --stat server master
popd

This solved all our problems described above:

  • we can distribute links to the mirror repository
  • we can use the bare repository as central repository for file exchange/joint work
  • updates are done incrementally
matheburg
  • 2,097
  • 1
  • 19
  • 46