git 上奇怪的钩子脚本执行

发布于 2024-10-26 04:57:51 字数 695 浏览 5 评论 0原文

这有点奇怪,所以我在接收后的远程 git repo 挂钩脚本中添加了这一行:

cd /path/to/my/deployed/app
git reset --hard
rm files/.development

从我的本地计算机推送到我的 git repo - 这就是奇怪的地方。我的接收后末尾的那些行是在我的本地计算机中执行的,而不是在我的远程服务器中执行的?

显然我最终得到了这个错误:

MacBook-Air:$ git push to-my-deployed-app

Counting objects: 23, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (16/16), 2.56 KiB, done.
Total 16 (delta 11), reused 0 (delta 0)
remote: warning: updating the current branch
remote: fatal: Not a git repository: '.'
remote: rm: cannot remove `files/.development': No such file or directory

所以那里..非常奇怪......

This is a little weird so I have this line in my remote git repo hook script post-receive:

cd /path/to/my/deployed/app
git reset --hard
rm files/.development

And from my local machine i push to my git repo - here's what's weird. Those lines that is at the end of my post-receive is executed in my local machine and not in my remote server??

Obviously I end up getting this error:

MacBook-Air:$ git push to-my-deployed-app

Counting objects: 23, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (16/16), 2.56 KiB, done.
Total 16 (delta 11), reused 0 (delta 0)
remote: warning: updating the current branch
remote: fatal: Not a git repository: '.'
remote: rm: cannot remove `files/.development': No such file or directory

So there .. very odd...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

平生欢 2024-11-02 04:57:51

您认为为什么它在本地运行?每个错误之前的前缀 remote: 表明它来自远程。从这些错误来看,您的存储库的路径似乎是错误的。事实上,如果您尝试在挂钩所在的存储库中运行 git reset --hard ,则不需要更改目录 - 挂钩的当前工作目录将是顶层无论如何,该存储库。

Why do you think it's being run locally? The prefix remote: before each error indicates that it came from the remote. From those errors, it looks as if the path to your repository is wrong. In fact, you shouldn't need to change directory if you're trying to run git reset --hard in the repository the hook is in - the current working directory for the hook will be the top level of that repository anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文