服务器上的裸机和非裸仓库 [英] Bare and non-bare repo at the server

查看:99
本文介绍了服务器上的裸机和非裸仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想跟踪存储在服务器上的目录和文件.最初的想法是在服务器上建立一个裸存储库,然后从本地计算机(存储非裸存储库的本地计算机)进行推/拉.问题在于服务器上必须存在更新的文件.

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.

最初,我专注于在服务器上设置非裸仓库并从裸仓库中拉出,但是每次从本地计算机上进行推送时,都需要有人git pull.我的问题是:是否可以以允许我对本地计算机上的代码进行更改,推送这些更改并将其自动保存到服务器的方式来设置裸机和非裸机回购协议.如果需要服务器端的非裸仓库,是否可以阻止从其推送?

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?

推荐答案

不是必须在服务器上手动使用git pull,而是可以使用

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

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

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.

这篇关于服务器上的裸机和非裸仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆