/.git/hooks/:无此类文件或目录协议错误:Mac osx上的预期控制记录 [英] /.git/hooks/: No such file or directory protocol error: expected control record on 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
这有两个原因:
- 在不正确的文件夹上执行钩子命令.确保在
checked-out
文件夹&的parent
文件夹上执行此命令.不在checked-out
文件夹上. - 在
master
分支以外的其他分支上执行钩子.在切换/签出其他分支之前,请确保在master
分支上运行hook命令.
- Executing hook command on incorrect folder. Makes sure to execute this command on
parent
folder of thechecked-out
folder & not onchecked-out
folder. - Executing hook on a different branch other than on the
master
branch. Make sure to run the hook command on themaster
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屋!