Bare and non-bare repo at the server

拜拜、爱过 提交于 2019-12-13 17:42:49

问题


I want to track directories and files stored at the server. The initial idea was to set up a bare repository at the server and then push/pull from local machines (where non-bare repos are stored). The problem is that updated files must be present at the server.

Initially I focused on setting up a non-bare repo on the server and pulling from the bare repo but it would require someone to git pull every time a push is made from a local machine. My question is: is it possible to set up bare and non-bare repos in a way that allows me to make changes to the code on a local machine, push those changes and have them at the server automatically. If a non-bare repo at the server side is needed, is it possible to block pushing from it?


回答1:


Instead of having to use git pull manually on the server, is it possible to use server-side hooks? This could be used to somehow trigger a pull for the non-bare repository on the server.

The post receive hook could be something like

#!/bin/bash

unset GIT_DIR
git -C /path/to/non/bare/repo pull

Another option, if you can afford to have some delay in the update of the server-side non-bare repository, would be to use a cron-job to periodically pull from the bare repository.



来源:https://stackoverflow.com/questions/54811380/bare-and-non-bare-repo-at-the-server

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