/.git/hooks/:无此类文件或目录协议错误:Mac osx上的预期控制记录 [英] /.git/hooks/: No such file or directory protocol error: expected control record on Mac osx

查看:1037
本文介绍了/.git/hooks/:无此类文件或目录协议错误:Mac osx上的预期控制记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天偶然发现此错误以浪费大量时间,同时尝试为存储库设置Gerrit钩子,并在通过XCode检出项目后在terminal上使用以下命令scp -p -P 29418 tttt@tttt.ttt.com:hooks/commit-msg .git/hooks/

Stumbled across this error today to waste a good amount of time, while trying to have gerrit hook setup for a repository, was using the following command scp -p -P 29418 tttt@tttt.ttt.com:hooks/commit-msg .git/hooks/ on terminal after having checked-out the project via XCode

这有两个原因:

  1. 在不正确的文件夹上执行钩子命令.确保在checked-out文件夹&的parent文件夹上执行此命令.不在checked-out文件夹上.
  2. master分支以外的其他分支上执行钩子.在切换/签出其他分支之前,请确保在master分支上运行hook命令.
  1. Executing hook command on incorrect folder. Makes sure to execute this command on parent folder of the checked-out folder & not on checked-out folder.
  2. Executing hook on a different branch other than on the master branch. Make sure to run the hook command on the master branch, before switching/checking-out a different branch.

推荐答案

请确保您尝试从正确的文件夹中安装钩子,该文件夹是存储库的根文件夹(包含.git文件夹)

Make sure that you are trying to install the hook from the correct folder, which is the root folder of the repository (which contains the .git folder)

就我而言,我使用SourceTree克隆了存储库,省略了将存储库放在根文件夹中的操作.因此,我在Finder上手动创建的文件夹中有一堆文件.

In my case, I have cloned the repo using SourceTree, which omitted putting the repo inside a root folder. So, there were a bunch of files inside a folder that I have manually created on Finder.

要解决此问题,我通过终端重新克隆了该项目,它将文件放在具有项目名称的根文件夹中;然后一切正常.

To fix it, I re-cloned the project through the terminal, it puts the files inside a root folder with the name of the project; then everything worked fine.

这篇关于/.git/hooks/:无此类文件或目录协议错误:Mac osx上的预期控制记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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