是否可以在裸存储库上的 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 callingmv
right after.
确切地说:在实际工作树(
/path/to/worktree/
)之后,而不是当前的 bare repo .对文件的任何操作都需要在 checkout 的仓库而不是裸仓库中完成。另一种方法是 push directly to a non-bare repo ,但您的方法更安全(首先更新一个裸仓库,然后在其他地方 checkout/更新)。
关于Git:在接收后移动文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37309306/