1

As I read on git documentation bare repositories are good for sharing and non-bare repositories are good for developing.
I'm setting up a development server which should provide SCM, Jenkins, and serve webpages to do some manual testing.
To provide SCM I use GOGS which creates bare repos to share between developers, I need that these bare repos somehow get hardlinked to non-bare repos on the apache folder (usually /var/www/http/) and mimic all the changes on the bare repo automatically.

Is it possible?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Gonzo RI
  • 71
  • 1
  • 10
  • Yes, create a bash(run it in cron job every 5 minutes) script and clone specific branch to you local apache folder (`git clone /path/to/your/local/bare/repo`). – IamK Dec 20 '16 at 22:24
  • I considered cloning the whole repo, but it seemed pretty inefficient, one of the reasons to use git is to minimize traffic and moving data. – Gonzo RI Dec 20 '16 at 22:36
  • You can trigger the cloning when a specific event happens using git hooks – IamK Dec 20 '16 at 22:38

2 Answers2

1

provide SCM I use GOGS which creates bare repos to share between developers, I need that these bare repos somehow get hardlinked to non-bare repos on the Apache folder (usually /var/www/http/)

That is generally done by a post-receive hook set in your bare repo managed by GOGS.
That script would be:

git --git-dir=/path/to/project_root/.git --work-tree=/var/www/http/ checkout -f

Any commit pushed to those bare repo will be visible in your web site.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

To make a non-bare repo, git clone the bare repo into the desired location.

As an aside, I would not recommend developing in the same location that is used for deployment. It eventually constrains you in really undesirable ways. Instead, build a small script that makes your "deployment bundle", a tgz or zip file that contains the items that need to be unpacked in your web server.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138