Git:在接收后移动文件夹

标签 git shell ubuntu

是否可以在裸存储库上的 post-receive(或任何其他 Hook )中移动/重命名文件夹?

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

当我尝试推送到存储库时,出现错误:
remote: mv: cannot stat `/path/to/worktree/src': No such file or directory

我确信该文件夹存在于我的本地分支中。

最佳答案

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/ )之后,而不是当前的 bare repo .对文件的任何操作都需要在 checkout 的仓库而不是裸仓库中完成。

另一种方法是 push directly to a non-bare repo ,但您的方法更安全(首先更新一个裸仓库,然后在其他地方 checkout/更新)。

关于Git:在接收后移动文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37309306/

相关文章:

c++ - 在 Ubuntu 中使用值大于 1000000 的 usleep 是否安全

windows - Git Bash for Windows 的提示到底在哪里定义?

Git 推送 : fatal: Out of memory, malloc 失败

git - 通过 rebase 保持远程存储库同步

linux - 如何从 bash 中的 .csv 文件的第一行获取特定列?

java - 如何在 ubuntu 中运行一个有很多 jars 依赖的 java 文件

git - 从 .git 目录生成工作目录文件

windows - 如何将 GUID 附加到现有文件名并保存到 CSV

linux - 使用函数路径中较早的函数

linux - 无法找到包 gcc-4.6-base :i386