git 上奇怪的钩子脚本执行
这有点奇怪,所以我在接收后的远程 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您认为为什么它在本地运行?每个错误之前的前缀
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 rungit 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.