Search code examples
gitgitlabpushgit-bare

Add git repository to existing folder on VSP


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?


Solution

  • 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