0

My Setup looks like this:

Bare Repo in my Root /srv Folder

Local Repo on my PC

Gitlab Repo on well Gitlab

I added two origins (Gitlab and my Bare Repo) to push all changes from my local machine to the source.
Now I want to set up a post-receive Hook in my Bare Repo so it will update the working directory on my VSP (where the Bare Repo lies)

But I already developed before without git (all the files are the same), I don´t want to clone the Repo in another directory, but just add the .git Folder to my var/www/project.
Is that possible with git?
Or is there no clean way around cloning the Repo and change folders?

Hugo y
  • 1,263
  • 9
  • 19
Isengo
  • 1,744
  • 1
  • 18
  • 36
  • I'm having trouble understanding what you are trying to do with the two remotes. What do you need - multiple workspaces/working-copies? – javabrett Jan 10 '17 at 23:15

2 Answers2

1

I don´t want to clone the Repo in annother directory, but just add the .git Folder to my var/www/project

Usually, you use the post-receive hook set in the bare repo to checkout said repo into the destination folder:

git --git-dir=/path/to/project_root/.git --work-tree=/var/www/project/ checkout -f
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • I also have this configuration on annother project, is there no .git folder necessary to checkout those changes to my production/live system? (/var/www/project/) – Isengo Jan 11 '17 at 11:18
  • @Isengo you don't need any `.git` in the destination folder `/var/www/project/`, since you are using the .git of your bare repo (`--git-dir`) – VonC Jan 11 '17 at 12:26
  • @Isengo I would not recommend yupengzhang's solution. The .git you have is made for a bare repo, and for pushing to it. A simple checkout is more appropriate here. – VonC Jan 11 '17 at 12:27
0

My solution is get the .git from one cloned workcopy and copy .git to your var/www/project. As all the contents are the same, so the workspace is clean.

May this help you :P