Git:接收后移动文件夹 [英] Git: move folder on post-receive

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

问题描述

是否可以在裸仓库中的后接收(或任何其他挂钩)中移动/重命名文件夹?

Is it possible to move/rename a folder in a post-receive (or any other hook) on a bare repository?

#!/bin/sh
mv /path/to/worktree/src /path/to/worktree/public

当我尝试推送到存储库时,出现错误:

When I try to push to the repository I get an error:

remote: mv: cannot stat `/path/to/worktree/src': No such file or directory

我确定该文件夹存在于我的本地分支中.

I am sure that the folder exists in my local branch.

推荐答案

后期接收中,我正在呼叫git --work-tree=/path/to/worktree/ --git-dir=/path/to/repo/ checkout -f master
因此,也许只是在此之后立即调用mv的问题.

Later in post-receive I am calling git --work-tree=/path/to/worktree/ --git-dir=/path/to/repo/ checkout -f master
So, perhaps it's just a matter of calling mv right after.

完全是:紧接在实际工作树(/path/to/worktree/)中的中,而不是当前的

Exactly: right after, and in an actual worktree (/path/to/worktree/) instead of the current bare repo. Any action on files needs to be done in a checked out repo instead of a bare repo.

另一种方法是直接推送到非裸仓库,但是您的方法更安全(第一次更新裸仓库,然后在其他地方结帐/更新).

The other approach would be to push directly to a non-bare repo, but your approach is safer (first updating a bare repo, then checkout/update elsewhere).

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

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