从Linux上的裸git存储库中检出所选文件和文件夹的最佳方法是什么? [英] What's the best way to checkout selected files and folders from a bare git repository on linux?

查看:131
本文介绍了从Linux上的裸git存储库中检出所选文件和文件夹的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在GoDaddy共享托管帐户上为网站建立git存储库.通常,人们会在服务器上设置 git裸仓库 a>仅包含实时网络数据,然后在 git post-receive钩子签出到实时目录(感谢@VonC的链接).

I'm setting up a git repository for a website on a GoDaddy shared hosting account. Normally one would set up a git bare repo on the server that contained the live web data only, then on a push to the remote use a git post-receive hook to checkout to the live directory (thanks to @VonC for the links).

很好,但是我已经将存储库设置为也包含工作文件.在我拥有的服务器上,

That's fine, but I've set up the repository to include work files as well. On the server I have,

/home/username/repo.git/work_folders和/home/username/repo/web_files_and_folders

/home/username/repo.git/work_folders, and /home/username/repo/web_files_and_folders

用于存储库,

/home/username/public_html/web_files_and_folders

/home/username/public_html/web_files_and_folders

用于实时文件和文件夹.

for the live files and folders.

work_folders通常包含svg,png和jpg文件,用于为网站生成png和jpg文件.这些是网站开发过程中的主文件.

The work_folders usually contain svg, png and jpg files used to generate the png and jpg files for the website. These are master files which are part of the development of the website.

问题是我找不到一种简单的方法来让git签出web_files_and_folders只能从任何给定分支中使用.我可以使用 shell进行通配符选择 web_files_and_folders,但这并不能解决知道分支名称的问题(当然,每个分支的名称可能会发生变化).

The thing is I can't find an easy way to get git to checkout the web_files_and_folders only to live from any given branch. I could use the shell to wildcard select the web_files_and_folders but that doesn't solve knowing the branch name (which could change of course with each branch).

我是否需要合并到master(例如),然后在post-receive挂钩中使用shell通配符?如果是这样,那对于其他我不太想使用该回购协议的较精通技术的人来说可能是个问题.

Do I need to merge to master (for instance) and then do the shell wildcard in the post-receive hook? If so, that may be a problem for other less tech savy people I'm trying to get to use the repo.

编辑-------------------

EDIT -------------------

因此,要进行更新.在我输入的终端外壳中,

So, to update. From a terminal shell I entered,

GIT_WORK_TREE=/home/user/public_html/dev git checkout -f dev devpath/web/*

从Web文件夹中提取了正确的文件,但没有获取

which extracted the right files from the web folder but rather than getting,

/home/user/public_html/dev/*

我知道了

/home/user/public_html/dev/devpath/web/*

很明显,我缺少有关如何更改提取路径的信息.

Evidently I'm missing something about how to change the extract path.

编辑2 -------------------

EDIT 2 -------------------

好,更多细节...

我目前在共享服务器上的裸存储库设置中,

I currently have a bare repo setup on a shared server at,

/home/user/repo.git

本地存储库有两个分支,即dev和master,其文件格式为

The local repository has 2 branches, dev and master, with a file format like,

/devpath/logos/
/devpath/photos/
...
/devpath/web/  (website root files and folders)

这个想法是在dev分支中进行开发,推送到服务器并在网站的dev.url上进行测试,当一切正常时,将dev分支合并到master中,推送到服务器并上线.目前,我们两个人正在开发该网站.

The idea is to develop in the dev branch, push to the server and test on the dev.url of the website, and when things are good merge the dev branch into the master, push to the server and go live. Currently 2 of us are developing the website.

接收后挂钩尚未完成,但与

The post-receive hook isn't completed yet but is similar to this one. My use is pretty much the same as this link except I want the remote repository to store the other development files. These files are part of the website development and need to be shared.

您在第一次编辑中看到的是尝试将dev分支检出到dev测试站点.在服务器上,此测试站点是一个子域,可以作为文件系统中公共html根目录下的文件夹进行访问.

What you saw in my first edit was an attempt to checkout the dev branch to the dev test site. On the server this test site is a subdomain and is accessed as a folder under the public html root in the filesystem.

在我看来,就像使用通配符选择器签出一样,

It looks to me like checking out with a wildcard selector,

GIT_WORK_TREE=/home/user/public_html/dev git checkout -f dev devpath/web/*

还将文件放在通配符之前的相同路径下.我需要能够定义一个新的默认路径.

also puts the files under that same path prior to the wildcard. I need to be able to define a new default path.

我在服务器上安装了Git 1.7.1.

I have Git 1.7.1 on the server.

推荐答案

通过管道解决此问题:

Solve this with plumbing:

GIT_WORK_TREE=deploy/path GIT_INDEX_FILE=manifest/path \
        git read-tree -um commit:web_files_and_folders

这篇关于从Linux上的裸git存储库中检出所选文件和文件夹的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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