/.git/hooks/: No such file or directory protocol error: expected control record on Mac osx
Asked Answered
S

3

3

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 [email protected]:hooks/commit-msg .git/hooks/ on terminal after having checked-out the project via XCode

Two reasons for this are:

  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.
Strobilaceous answered 6/8, 2015 at 11:6 Comment(1)
@Stephen, I wanted to share this information, since I couldn't find any related question listed created one for it. Also have shared the initial cause and solution for others to benefit and contribute.Strobilaceous
D
2

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)

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.

Disservice answered 11/8, 2015 at 14:42 Comment(0)
S
0

Wanted to answer even though this is kind of old , but who ever faces this still can benefit from by findings

We had similar error when downloading commit message hook

gerrit protocol error : expected control record

Usually hooks are stored in project_folder/.git/hooks/

And you will find file with name commit-msg

On looking further the file was owned by root causing above issue

When changing the permission to my account solved the problem

Spoke answered 7/4, 2020 at 13:16 Comment(0)
P
0

Another possibility is that the scp command is (under the hood) seeing data that it does not understand. If your login scripts (e.g., ~/.bashrc or ~/.kshrc) generate output in non-interactive sessions then scp will fail with the "expected control record" error.

Additional details (for one specific setup) here.

Photoengrave answered 15/7, 2020 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.