Git后接收钩.移动除几个文件夹以外的所有内容 [英] Git post-receive hook. Move everything except a few folders

查看:50
本文介绍了Git后接收钩.移动除几个文件夹以外的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在服务器上实现了接收后钩子(git已用git init --bare初始化).挂钩是通过以下方式创建的:

I have implemented a post-receive hook on my server (git was initialized with git init --bare). Hook was created in the following way:

cd repo/hooks/
touch post-receive
chmod 777 post-receive

然后在文件中找到我

#!/bin/sh
GIT_WORK_TREE=/var/www
export GIT_WORK_TREE
git checkout -f

现在,当我推送本地更改时,所有内容都移至/var/www文件夹.问题是我不想移动某些文件夹.例如,我有folder1folder2,我不想将其移到那里.目前,我在推送后手动删除了这些文件夹,但这是一项荒谬的工作,我想使其自动化.

Right now when I push my local changes everything gets moved to /var/www folder. The problem is that I do not want some of the folders to be moved. For example I have folder1, and folder2 there which I do not want to be moved. Currently I am manually removing these folders after the push, but this is a ridiculous work and I would like to automate it.

我在ubuntu 14.04/git 2.1

推荐答案

我要在推送后手动删除这些文件夹

I am manually removing these folders after the push

您可以在此步骤中投放广告

You could just ad this step in your hook

另一种方法是尝试设置稀疏结帐(因为您可以

The other way is to try and set up a sparse checkout (since you can exclude folders in the sparse-checkout file).

echo "/*" > .git/info/sparse-checkout
echo "!folder1/" >> .git/info/sparse-checkout
echo "!folder2/" >> .git/info/sparse-checkout

这篇关于Git后接收钩.移动除几个文件夹以外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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