问题
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