1

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?

4

1 回答 1

2

不必git pull在服务器上手动使用,是否可以使用服务器端挂钩?这可以用来以某种方式触发服务器上非裸存储库的拉取。

post接收钩子可能类似于

#!/bin/bash

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

另一种选择,如果您可以承受更新服务器端非裸存储库的一些延迟,则可以使用 cron-job 定期从裸存储库中提取。

于 2019-02-21T16:59:02.967 回答